From 24032fe1107859edfdcaac5b1804a8904b44971d Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 27 Dec 2022 13:59:23 +0000 Subject: [PATCH] pypy: re-enable PyFunction on 3.8+ --- newsfragments/2838.changed.md | 1 + pyo3-ffi/src/cpython/funcobject.rs | 4 ++-- src/types/function.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 newsfragments/2838.changed.md diff --git a/newsfragments/2838.changed.md b/newsfragments/2838.changed.md new file mode 100644 index 00000000..d459d239 --- /dev/null +++ b/newsfragments/2838.changed.md @@ -0,0 +1 @@ +Re-enable `PyFunction` on when building for abi3 or PyPy. diff --git a/pyo3-ffi/src/cpython/funcobject.rs b/pyo3-ffi/src/cpython/funcobject.rs index 1d36c85e..443988dd 100644 --- a/pyo3-ffi/src/cpython/funcobject.rs +++ b/pyo3-ffi/src/cpython/funcobject.rs @@ -53,12 +53,12 @@ pub struct PyFunctionObject { #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { - #[cfg(not(PyPy))] // broken, see https://foss.heptapod.net/pypy/pypy/-/issues/3776 + #[cfg(not(all(PyPy, not(Py_3_8))))] #[cfg_attr(PyPy, link_name = "PyPyFunction_Type")] pub static mut PyFunction_Type: crate::PyTypeObject; } -#[cfg(not(PyPy))] +#[cfg(not(all(PyPy, not(Py_3_8))))] #[inline] pub unsafe fn PyFunction_Check(op: *mut PyObject) -> c_int { (crate::Py_TYPE(op) == addr_of_mut_shim!(PyFunction_Type)) as c_int diff --git a/src/types/function.rs b/src/types/function.rs index f02c36bc..8ffac550 100644 --- a/src/types/function.rs +++ b/src/types/function.rs @@ -179,8 +179,8 @@ impl PyCFunction { /// Represents a Python function object. #[repr(transparent)] -#[cfg(not(any(PyPy, Py_LIMITED_API)))] +#[cfg(all(not(Py_LIMITED_API), not(all(PyPy, not(Py_3_8)))))] pub struct PyFunction(PyAny); -#[cfg(not(any(PyPy, Py_LIMITED_API)))] +#[cfg(all(not(Py_LIMITED_API), not(all(PyPy, not(Py_3_8)))))] pyobject_native_type_core!(PyFunction, ffi::PyFunction_Type, #checkfunction=ffi::PyFunction_Check);