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

update object.h definitions for Python 3.12 #3335

Merged
merged 2 commits into from
Jul 30, 2023
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/3335.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update FFI definitions of `object.h` for Python 3.12 and up.
1 change: 1 addition & 0 deletions newsfragments/3335.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix reference counting of immortal objects on Python 3.12 betas.
12 changes: 3 additions & 9 deletions pyo3-ffi/src/cpython/object.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::object;
#[cfg(Py_3_8)]
use crate::vectorcallfunc;
use crate::{PyObject, Py_ssize_t};
use std::mem;
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void};
Expand Down Expand Up @@ -112,14 +114,6 @@ mod bufferinfo {
#[cfg(not(Py_3_11))]
pub use self::bufferinfo::*;

#[cfg(Py_3_8)]
pub type vectorcallfunc = unsafe extern "C" fn(
callable: *mut PyObject,
args: *const *mut PyObject,
nargsf: libc::size_t,
kwnames: *mut PyObject,
) -> *mut PyObject;

#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyNumberMethods {
Expand Down Expand Up @@ -275,7 +269,7 @@ pub struct PyTypeObject {
pub tp_version_tag: c_uint,
pub tp_finalize: Option<object::destructor>,
#[cfg(Py_3_8)]
pub tp_vectorcall: Option<super::vectorcallfunc>,
pub tp_vectorcall: Option<vectorcallfunc>,
#[cfg(Py_3_12)]
pub tp_watched: c_char,
#[cfg(any(all(PyPy, Py_3_8, not(Py_3_10)), all(not(PyPy), Py_3_8, not(Py_3_9))))]
Expand Down
10 changes: 5 additions & 5 deletions pyo3-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ macro_rules! opaque_struct {
pub use self::abstract_::*;
pub use self::bltinmodule::*;
pub use self::boolobject::*;
#[cfg(Py_3_11)]
pub use self::buffer::*;
pub use self::bytearrayobject::*;
pub use self::bytesobject::*;
pub use self::ceval::*;
Expand Down Expand Up @@ -293,6 +291,8 @@ pub use self::objimpl::*;
pub use self::osmodule::*;
#[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))]
pub use self::pyarena::*;
#[cfg(Py_3_11)]
pub use self::pybuffer::*;
pub use self::pycapsule::*;
pub use self::pyerrors::*;
pub use self::pyframe::*;
Expand Down Expand Up @@ -320,8 +320,6 @@ mod abstract_;
// skipped ast.h
mod bltinmodule;
mod boolobject;
#[cfg(Py_3_11)]
mod buffer;
mod bytearrayobject;
mod bytesobject;
// skipped cellobject.h
Expand Down Expand Up @@ -372,8 +370,9 @@ mod osmodule;
// skipped py_curses.h
#[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))]
mod pyarena;
#[cfg(Py_3_11)]
mod pybuffer;
mod pycapsule;
// skipped pydecimal.h
// skipped pydtrace.h
mod pyerrors;
// skipped pyexpat.h
Expand All @@ -387,6 +386,7 @@ mod pylifecycle;
mod pymem;
mod pyport;
mod pystate;
// skipped pystats.h
mod pythonrun;
// skipped pystrhex.h
// skipped pystrcmp.h
Expand Down
Loading