Skip to content

Commit 5564d61

Browse files
committed
update object.h definitions for Python 3.12
1 parent 0f1846c commit 5564d61

File tree

9 files changed

+374
-129
lines changed

9 files changed

+374
-129
lines changed

newsfragments/3335.changed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update FFI definitions of `object.h` for Python 3.12 and up.

newsfragments/3335.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix reference counting of immortal objects on Python 3.12 betas.

pyo3-ffi/src/cpython/object.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use crate::object;
2+
#[cfg(Py_3_8)]
3+
use crate::vectorcallfunc;
24
use crate::{PyObject, Py_ssize_t};
35
use std::mem;
46
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void};
@@ -112,14 +114,6 @@ mod bufferinfo {
112114
#[cfg(not(Py_3_11))]
113115
pub use self::bufferinfo::*;
114116

115-
#[cfg(Py_3_8)]
116-
pub type vectorcallfunc = unsafe extern "C" fn(
117-
callable: *mut PyObject,
118-
args: *const *mut PyObject,
119-
nargsf: libc::size_t,
120-
kwnames: *mut PyObject,
121-
) -> *mut PyObject;
122-
123117
#[repr(C)]
124118
#[derive(Copy, Clone)]
125119
pub struct PyNumberMethods {
@@ -275,7 +269,7 @@ pub struct PyTypeObject {
275269
pub tp_version_tag: c_uint,
276270
pub tp_finalize: Option<object::destructor>,
277271
#[cfg(Py_3_8)]
278-
pub tp_vectorcall: Option<super::vectorcallfunc>,
272+
pub tp_vectorcall: Option<vectorcallfunc>,
279273
#[cfg(Py_3_12)]
280274
pub tp_watched: c_char,
281275
#[cfg(any(all(PyPy, Py_3_8, not(Py_3_10)), all(not(PyPy), Py_3_8, not(Py_3_9))))]

pyo3-ffi/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ macro_rules! addr_of_mut_shim {
274274
pub use self::abstract_::*;
275275
pub use self::bltinmodule::*;
276276
pub use self::boolobject::*;
277-
#[cfg(Py_3_11)]
278-
pub use self::buffer::*;
279277
pub use self::bytearrayobject::*;
280278
pub use self::bytesobject::*;
281279
pub use self::ceval::*;
@@ -308,6 +306,8 @@ pub use self::objimpl::*;
308306
pub use self::osmodule::*;
309307
#[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))]
310308
pub use self::pyarena::*;
309+
#[cfg(Py_3_11)]
310+
pub use self::pybuffer::*;
311311
pub use self::pycapsule::*;
312312
pub use self::pyerrors::*;
313313
pub use self::pyframe::*;
@@ -335,8 +335,6 @@ mod abstract_;
335335
// skipped ast.h
336336
mod bltinmodule;
337337
mod boolobject;
338-
#[cfg(Py_3_11)]
339-
mod buffer;
340338
mod bytearrayobject;
341339
mod bytesobject;
342340
// skipped cellobject.h
@@ -387,8 +385,9 @@ mod osmodule;
387385
// skipped py_curses.h
388386
#[cfg(not(any(PyPy, Py_LIMITED_API, Py_3_10)))]
389387
mod pyarena;
388+
#[cfg(Py_3_11)]
389+
mod pybuffer;
390390
mod pycapsule;
391-
// skipped pydecimal.h
392391
// skipped pydtrace.h
393392
mod pyerrors;
394393
// skipped pyexpat.h
@@ -402,6 +401,7 @@ mod pylifecycle;
402401
mod pymem;
403402
mod pyport;
404403
mod pystate;
404+
// skipped pystats.h
405405
mod pythonrun;
406406
// skipped pystrhex.h
407407
// skipped pystrcmp.h

0 commit comments

Comments
 (0)