pyo3/tests/test_unsendable_dict.rs
Sebastian Puetz e75f768ea8 Move the ThreadChecker field in front of dict and weakref.
Offsets for dict and weakref are calculated from the end of the
PyCell struct. When using the non-dummy ThreadChecker, the offsets
were invalid since the `ThreadCheckerImpl` is not zero-sized.
2020-07-20 19:37:38 +02:00

22 lines
431 B
Rust

use pyo3::prelude::*;
use pyo3::py_run;
#[pyclass(dict, unsendable)]
struct UnsendableDictClass {}
#[pymethods]
impl UnsendableDictClass {
#[new]
fn new() -> Self {
UnsendableDictClass {}
}
}
#[test]
fn test_unsendable_dict() {
let gil = Python::acquire_gil();
let py = gil.python();
let inst = Py::new(py, UnsendableDictClass {}).unwrap();
py_run!(py, inst, "assert inst.__dict__ == {}");
}