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

This commit is contained in:
Thomas Tanon 2024-03-06 19:19:43 +01:00 committed by GitHub
parent d35f41e0bf
commit 0f7ddb19a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1 @@
Remove `PyCode` and `PyCode_Type` on PyPy: `PyCode_Type` is not exposed by PyPy.

View File

@ -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;

View File

@ -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");
})
}
}

View File

@ -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)]
@ -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))]