From f8ca456f5f2a35e75cf32873a02bce181340d123 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 23 Jul 2023 16:32:02 +0200 Subject: [PATCH] Add PyType_GetDict for Python 3.12 --- newsfragments/3339.added.md | 1 + pyo3-ffi/src/cpython/object.rs | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 newsfragments/3339.added.md diff --git a/newsfragments/3339.added.md b/newsfragments/3339.added.md new file mode 100644 index 00000000..88884bfd --- /dev/null +++ b/newsfragments/3339.added.md @@ -0,0 +1 @@ +Define `PyType_GetDict()` FFI for CPython 3.12 or later. diff --git a/pyo3-ffi/src/cpython/object.rs b/pyo3-ffi/src/cpython/object.rs index 76ab074f..8209524f 100644 --- a/pyo3-ffi/src/cpython/object.rs +++ b/pyo3-ffi/src/cpython/object.rs @@ -349,6 +349,9 @@ pub unsafe fn PyHeapType_GET_MEMBERS( // skipped _PyType_GetModuleByDef extern "C" { + #[cfg(Py_3_12)] + pub fn PyType_GetDict(o: *mut PyTypeObject) -> *mut PyObject; + #[cfg_attr(PyPy, link_name = "PyPyObject_Print")] pub fn PyObject_Print(o: *mut PyObject, fp: *mut ::libc::FILE, flags: c_int) -> c_int;