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.
This commit is contained in:
parent
53a248c617
commit
e75f768ea8
|
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
|
||||
### Fixed
|
||||
- Conversion from types with an `__index__` method to Rust BigInts. [#1027](https://github.com/PyO3/pyo3/pull/1027)
|
||||
- Fix segfault with #[pyclass(dict, unsendable)] [#1058](https://github.com/PyO3/pyo3/pull/1058)
|
||||
|
||||
## [0.11.1] - 2020-06-30
|
||||
### Added
|
||||
|
|
|
@ -161,9 +161,9 @@ impl<T: PyClass> PyCellInner<T> {
|
|||
#[repr(C)]
|
||||
pub struct PyCell<T: PyClass> {
|
||||
inner: PyCellInner<T>,
|
||||
thread_checker: T::ThreadChecker,
|
||||
dict: T::Dict,
|
||||
weakref: T::WeakRef,
|
||||
thread_checker: T::ThreadChecker,
|
||||
}
|
||||
|
||||
unsafe impl<T: PyClass> PyNativeType for PyCell<T> {}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
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__ == {}");
|
||||
}
|
Loading…
Reference in New Issue