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

Added new PyCode and PyFrame objects. #2408

Merged
merged 1 commit into from Jun 1, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added the internal `IntoPyResult` trait to give better error messages when function return types do not implement `IntoPy`. [#2326](https://github.com/PyO3/pyo3/pull/2326)
- Add `PyDictKeys`, `PyDictValues` and `PyDictItems` Rust types to represent `dict_keys`, `dict_values` and `dict_items` types. [#2358](https://github.com/PyO3/pyo3/pull/2358)
- Add macro `append_to_inittab`. [#2377](https://github.com/PyO3/pyo3/pull/2377)
- Added `PyCode` and `PyFrame` high level objects. [#2408](https://github.com/PyO3/pyo3/pull/2408)

### Changed

Expand Down
14 changes: 14 additions & 0 deletions 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
);
14 changes: 14 additions & 0 deletions 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
);
8 changes: 8 additions & 0 deletions src/types/mod.rs
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down