Skip to content

Commit

Permalink
update object.h definitions for Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jul 30, 2023
1 parent 0f1846c commit 5564d61
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 129 deletions.
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 @@ -274,8 +274,6 @@ macro_rules! addr_of_mut_shim {
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 @@ -308,6 +306,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 @@ -335,8 +335,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 @@ -387,8 +385,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 @@ -402,6 +401,7 @@ mod pylifecycle;
mod pymem;
mod pyport;
mod pystate;
// skipped pystats.h
mod pythonrun;
// skipped pystrhex.h
// skipped pystrcmp.h
Expand Down
Loading

0 comments on commit 5564d61

Please sign in to comment.