Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPy: remove PyCode (PyCode_Type does not exist) #3934

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/3934.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `PyCode` and `PyCode_Type` on PyPy: `PyCode_Type` is not exposed by PyPy.
1 change: 1 addition & 0 deletions pyo3-ffi/src/cpython/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pub const CO_FUTURE_GENERATOR_STOP: c_int = 0x8_0000;

pub const CO_MAXBLOCKS: usize = 20;

#[cfg(not(PyPy))]
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
pub static mut PyCode_Type: PyTypeObject;
Expand Down
14 changes: 14 additions & 0 deletions src/types/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ pyobject_native_type_core!(
pyobject_native_static_type_object!(ffi::PyCode_Type),
#checkfunction=ffi::PyCode_Check
);

#[cfg(test)]
mod tests {
use super::*;
use crate::types::PyTypeMethods;
use crate::{PyTypeInfo, Python};

#[test]
fn test_type_object() {
Python::with_gil(|py| {
assert_eq!(PyCode::type_object_bound(py).name().unwrap(), "code");
})
}
}
4 changes: 2 additions & 2 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub use self::boolobject::{PyBool, PyBoolMethods};
pub use self::bytearray::{PyByteArray, PyByteArrayMethods};
pub use self::bytes::{PyBytes, PyBytesMethods};
pub use self::capsule::{PyCapsule, PyCapsuleMethods};
#[cfg(not(Py_LIMITED_API))]
#[cfg(all(not(Py_LIMITED_API), not(PyPy)))]
pub use self::code::PyCode;
pub use self::complex::{PyComplex, PyComplexMethods};
#[allow(deprecated)]
Expand Down Expand Up @@ -316,7 +316,7 @@ pub(crate) mod boolobject;
pub(crate) mod bytearray;
pub(crate) mod bytes;
pub(crate) mod capsule;
#[cfg(not(Py_LIMITED_API))]
#[cfg(all(not(Py_LIMITED_API), not(PyPy)))]
mod code;
pub(crate) mod complex;
#[cfg(not(Py_LIMITED_API))]
Expand Down
Loading