Skip to content

Commit

Permalink
pypy: disable PyFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Aug 11, 2022
1 parent 6eb47c2 commit d7f1a0d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Only allow each `#[pymodule]` to be initialized once. [#2523](https://github.com/PyO3/pyo3/pull/2523)
- `pyo3_build_config::add_extension_module_link_args()` now also emits linker arguments for `wasm32-unknown-emscripten`. [#2538](https://github.com/PyO3/pyo3/pull/2538)
- Downcasting (`PyTryFrom`) behavior has changed for `PySequence` and `PyMapping`: classes are now required to inherit from (or register with) the corresponding Python standard library abstract base class. See the [migration guide](https://pyo3.rs/latest/migration.html) for information on fixing broken downcasts. [#2477](https://github.com/PyO3/pyo3/pull/2477)
- Disable `PyFunction` on `Py_LIMITED_API` and PyPy. [#2542](https://github.com/PyO3/pyo3/pull/2542)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::os::raw::c_int;

use crate::object::{PyObject, PyTypeObject, Py_TYPE};

#[cfg(all(not(PyPy), not(Py_LIMITED_API), not(Py_3_10)))]
#[cfg(all(not(PyPy), not(Py_3_10)))]
#[repr(C)]
pub struct PyFunctionObject {
pub ob_base: PyObject,
Expand All @@ -22,7 +22,7 @@ pub struct PyFunctionObject {
pub vectorcall: Option<crate::vectorcallfunc>,
}

#[cfg(all(not(PyPy), not(Py_LIMITED_API), Py_3_10))]
#[cfg(all(not(PyPy), Py_3_10))]
#[repr(C)]
pub struct PyFunctionObject {
pub ob_base: PyObject,
Expand All @@ -44,18 +44,16 @@ pub struct PyFunctionObject {
pub func_version: u32,
}

#[cfg(all(PyPy, not(Py_LIMITED_API)))]
#[cfg(PyPy)]
#[repr(C)]
pub struct PyFunctionObject {
pub ob_base: PyObject,
pub func_name: *mut PyObject,
}

#[cfg(all(not(PyPy), Py_LIMITED_API))]
opaque_struct!(PyFunctionObject);

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
#[cfg(not(PyPy))] // broken, see https://foss.heptapod.net/pypy/pypy/-/issues/3776
#[cfg_attr(PyPy, link_name = "PyPyFunction_Type")]
pub static mut PyFunction_Type: PyTypeObject;
}
Expand Down
2 changes: 2 additions & 0 deletions pyo3-ffi/src/cpython/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(crate) mod dictobject;
// skipped fileobject.h
// skipped fileutils.h
pub(crate) mod frameobject;
pub(crate) mod funcobject;
pub(crate) mod genobject;
pub(crate) mod import;
#[cfg(all(Py_3_8, not(PyPy)))]
Expand Down Expand Up @@ -44,6 +45,7 @@ pub use self::descrobject::*;
#[cfg(not(PyPy))]
pub use self::dictobject::*;
pub use self::frameobject::*;
pub use self::funcobject::*;
pub use self::genobject::*;
pub use self::import::*;
#[cfg(all(Py_3_8, not(PyPy)))]
Expand Down
4 changes: 0 additions & 4 deletions pyo3-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ pub use self::enumobject::*;
pub use self::fileobject::*;
pub use self::fileutils::*;
pub use self::floatobject::*;
#[cfg(not(Py_LIMITED_API))]
pub use self::funcobject::*;
pub use self::import::*;
pub use self::intrcheck::*;
pub use self::iterobject::*;
Expand Down Expand Up @@ -368,8 +366,6 @@ mod fileobject;
mod fileutils;
mod floatobject;
// skipped empty frameobject.h
#[cfg(not(Py_LIMITED_API))]
pub(crate) mod funcobject;
// skipped genericaliasobject.h
mod import;
// skipped interpreteridobject.h
Expand Down
3 changes: 2 additions & 1 deletion src/types/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl PyCFunction {

/// Represents a Python function object.
#[repr(transparent)]
#[cfg(not(any(PyPy, Py_LIMITED_API)))]
pub struct PyFunction(PyAny);

#[cfg(not(Py_LIMITED_API))]
#[cfg(not(any(PyPy, Py_LIMITED_API)))]
pyobject_native_type_core!(PyFunction, ffi::PyFunction_Type, #checkfunction=ffi::PyFunction_Check);
4 changes: 3 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ pub use self::floatob::PyFloat;
#[cfg(all(not(Py_LIMITED_API), not(PyPy)))]
pub use self::frame::PyFrame;
pub use self::frozenset::PyFrozenSet;
pub use self::function::{PyCFunction, PyFunction};
pub use self::function::PyCFunction;
#[cfg(all(not(Py_LIMITED_API), not(PyPy)))]
pub use self::function::PyFunction;
pub use self::iterator::PyIterator;
pub use self::list::PyList;
pub use self::mapping::PyMapping;
Expand Down

0 comments on commit d7f1a0d

Please sign in to comment.