Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/5653.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable subclassing `PyDict` on GraalPy (unsupported for now).
1 change: 1 addition & 0 deletions newsfragments/5653.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix FFI definition of `PyDictObject` on PyPy.
10 changes: 9 additions & 1 deletion pyo3-ffi/src/cpython/dictobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ opaque_struct!(pub PyDictKeysObject);
#[cfg(Py_3_11)]
opaque_struct!(pub PyDictValues);

#[cfg(not(GraalPy))]
#[cfg(not(any(GraalPy, PyPy)))]
#[repr(C)]
#[derive(Debug)]
pub struct PyDictObject {
Expand All @@ -28,6 +28,14 @@ pub struct PyDictObject {
pub ma_values: *mut PyDictValues,
}

#[cfg(PyPy)]
#[repr(C)]
#[derive(Debug)]
pub struct PyDictObject {
pub ob_base: PyObject,
_tmpkeys: *mut PyObject,
}

extern "C" {
// skipped _PyDict_GetItem_KnownHash
// skipped _PyDict_GetItemIdWithError
Expand Down
2 changes: 0 additions & 2 deletions pyo3-ffi/src/cpython/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(crate) mod complexobject;
#[cfg(Py_3_13)]
pub(crate) mod critical_section;
pub(crate) mod descrobject;
#[cfg(not(PyPy))]
pub(crate) mod dictobject;
// skipped fileobject.h
// skipped fileutils.h
Expand Down Expand Up @@ -53,7 +52,6 @@ pub use self::complexobject::*;
#[cfg(Py_3_13)]
pub use self::critical_section::*;
pub use self::descrobject::*;
#[cfg(not(PyPy))]
pub use self::dictobject::*;
pub use self::floatobject::*;
pub use self::frameobject::*;
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/src/dictobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ extern "C" {
pub static mut PyDictRevIterItem_Type: PyTypeObject;
}

#[cfg(any(PyPy, GraalPy, Py_LIMITED_API))]
#[cfg(any(GraalPy, Py_LIMITED_API))]
// TODO: remove (see https://github.com/PyO3/pyo3/pull/1341#issuecomment-751515985)
opaque_struct!(pub PyDictObject);
1 change: 1 addition & 0 deletions src/types/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{ffi, BoundObject, IntoPyObject, IntoPyObjectExt, Python};
#[repr(transparent)]
pub struct PyDict(PyAny);

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

pyobject_native_type!(
Expand Down
Loading