diff --git a/src/types/code.rs b/src/types/code.rs new file mode 100644 index 00000000000..fc7e3e9f83e --- /dev/null +++ b/src/types/code.rs @@ -0,0 +1,14 @@ +// Copyright (c) 2022-present PyO3 Project and Contributors + +use crate::ffi; +use crate::PyAny; + +/// Represents a Python code object. +#[repr(transparent)] +pub struct PyCode(PyAny); + +pyobject_native_type_core!( + PyCode, + ffi::PyCode_Type, + #checkfunction=ffi::PyCode_Check +); diff --git a/src/types/frame.rs b/src/types/frame.rs new file mode 100644 index 00000000000..c16e143987d --- /dev/null +++ b/src/types/frame.rs @@ -0,0 +1,14 @@ +// Copyright (c) 2022-present PyO3 Project and Contributors + +use crate::ffi; +use crate::PyAny; + +/// Represents a Python frame. +#[repr(transparent)] +pub struct PyFrame(PyAny); + +pyobject_native_type_core!( + PyFrame, + ffi::PyFrame_Type, + #checkfunction=ffi::PyFrame_Check +); diff --git a/src/types/mod.rs b/src/types/mod.rs index 861a4a3ebfe..00b72f5ea6e 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -7,6 +7,8 @@ pub use self::boolobject::PyBool; pub use self::bytearray::PyByteArray; pub use self::bytes::PyBytes; pub use self::capsule::PyCapsule; +#[cfg(not(Py_LIMITED_API))] +pub use self::code::PyCode; pub use self::complex::PyComplex; #[cfg(not(Py_LIMITED_API))] pub use self::datetime::{ @@ -16,6 +18,8 @@ pub use self::datetime::{ pub use self::dict::{IntoPyDict, PyDict}; pub use self::floatob::PyFloat; pub use self::frozenset::PyFrozenSet; +#[cfg(all(not(Py_LIMITED_API), not(PyPy)))] +pub use self::frame::PyFrame; pub use self::function::{PyCFunction, PyFunction}; pub use self::iterator::PyIterator; pub use self::list::PyList; @@ -257,12 +261,16 @@ mod boolobject; mod bytearray; mod bytes; mod capsule; +#[cfg(not(Py_LIMITED_API))] +mod code; mod complex; #[cfg(not(Py_LIMITED_API))] mod datetime; mod dict; mod floatob; mod frozenset; +#[cfg(all(not(Py_LIMITED_API), not(PyPy)))] +mod frame; mod function; mod iterator; mod list;