Skip to content

Commit 9e4798b

Browse files
committed
fix FFI definition of PyDictObject on PyPy
1 parent 19eff32 commit 9e4798b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

pyo3-ffi/src/cpython/dictobject.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ opaque_struct!(pub PyDictKeysObject);
77
#[cfg(Py_3_11)]
88
opaque_struct!(pub PyDictValues);
99

10-
#[cfg(not(GraalPy))]
10+
#[cfg(not(any(GraalPy, PyPy)))]
1111
#[repr(C)]
1212
#[derive(Debug)]
1313
pub struct PyDictObject {
@@ -28,6 +28,14 @@ pub struct PyDictObject {
2828
pub ma_values: *mut PyDictValues,
2929
}
3030

31+
#[cfg(PyPy)]
32+
#[repr(C)]
33+
#[derive(Debug)]
34+
pub struct PyDictObject {
35+
pub ob_base: PyObject,
36+
_tmpkeys: *mut PyObject,
37+
}
38+
3139
extern "C" {
3240
// skipped _PyDict_GetItem_KnownHash
3341
// skipped _PyDict_GetItemIdWithError

pyo3-ffi/src/cpython/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub(crate) mod complexobject;
99
#[cfg(Py_3_13)]
1010
pub(crate) mod critical_section;
1111
pub(crate) mod descrobject;
12-
#[cfg(not(PyPy))]
1312
pub(crate) mod dictobject;
1413
// skipped fileobject.h
1514
// skipped fileutils.h
@@ -53,7 +52,6 @@ pub use self::complexobject::*;
5352
#[cfg(Py_3_13)]
5453
pub use self::critical_section::*;
5554
pub use self::descrobject::*;
56-
#[cfg(not(PyPy))]
5755
pub use self::dictobject::*;
5856
pub use self::floatobject::*;
5957
pub use self::frameobject::*;

pyo3-ffi/src/dictobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@ extern "C" {
116116
pub static mut PyDictRevIterItem_Type: PyTypeObject;
117117
}
118118

119-
#[cfg(any(PyPy, GraalPy, Py_LIMITED_API))]
119+
#[cfg(any(GraalPy, Py_LIMITED_API))]
120120
// TODO: remove (see https://github.com/PyO3/pyo3/pull/1341#issuecomment-751515985)
121121
opaque_struct!(pub PyDictObject);

src/types/dict.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{ffi, BoundObject, IntoPyObject, IntoPyObjectExt, Python};
1616
#[repr(transparent)]
1717
pub struct PyDict(PyAny);
1818

19+
#[cfg(not(GraalPy))]
1920
pyobject_subclassable_native_type!(PyDict, crate::ffi::PyDictObject);
2021

2122
pyobject_native_type!(

0 commit comments

Comments
 (0)