Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new PyCode and PyFrame objects.
Browse files Browse the repository at this point in the history
They currently do not expose any APIs, but are significantly easier to work with than raw pointers :-)
alex committed May 31, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
1 parent 4f9d3d7 commit 71be64c
Showing 3 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/types/code.rs
Original file line number Diff line number Diff line change
@@ -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
);
14 changes: 14 additions & 0 deletions src/types/frame.rs
Original file line number Diff line number Diff line change
@@ -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
);
8 changes: 8 additions & 0 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -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::{
@@ -15,6 +17,8 @@ pub use self::datetime::{
};
pub use self::dict::{IntoPyDict, PyDict};
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::iterator::PyIterator;
@@ -257,11 +261,15 @@ 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;
#[cfg(all(not(Py_LIMITED_API), not(PyPy)))]
mod frame;
mod frozenset;
mod function;
mod iterator;

0 comments on commit 71be64c

Please sign in to comment.