Merge pull request #2557 from davidhewitt/ffi-py3.11

ffi: more fixes for Python 3.11 rc1
This commit is contained in:
David Hewitt 2022-08-16 18:50:35 +01:00 committed by GitHub
commit e34742e154
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 8 deletions

View file

@ -75,6 +75,9 @@ pub struct PyCodeObject {
pub co_qualname: *mut PyObject,
pub co_linetable: *mut PyObject,
pub co_weakreflist: *mut PyObject,
pub _co_code: *mut PyObject,
pub _co_firsttraceable: c_int,
pub _co_linearray: *mut c_char,
pub co_extra: *mut c_void,
pub co_code_adaptive: [c_char; 1],
}

View file

@ -55,6 +55,10 @@ pub struct _frozen {
pub name: *const c_char,
pub code: *const c_uchar,
pub size: c_int,
#[cfg(Py_3_11)]
pub is_package: c_int,
#[cfg(Py_3_11)]
pub get_code: Option<unsafe extern "C" fn() -> *mut PyObject>,
}
#[cfg_attr(windows, link(name = "pythonXY"))]

View file

@ -33,6 +33,7 @@ pub(crate) mod pythonrun;
// skipped sysmodule.h
pub(crate) mod tupleobject;
pub(crate) mod unicodeobject;
pub(crate) mod weakrefobject;
pub use self::abstract_::*;
#[cfg(not(PyPy))]
@ -63,3 +64,4 @@ pub use self::pystate::*;
pub use self::pythonrun::*;
pub use self::tupleobject::*;
pub use self::unicodeobject::*;
pub use self::weakrefobject::*;

View file

@ -292,6 +292,13 @@ pub struct PyTypeObject {
pub tp_next: *mut PyTypeObject,
}
#[cfg(Py_3_11)]
#[repr(C)]
#[derive(Clone)]
pub struct _specialization_cache {
pub getitem: *mut PyObject,
}
#[repr(C)]
#[derive(Clone)]
pub struct PyHeapTypeObject {
@ -308,6 +315,10 @@ pub struct PyHeapTypeObject {
pub ht_cached_keys: *mut c_void,
#[cfg(Py_3_9)]
pub ht_module: *mut object::PyObject,
#[cfg(Py_3_11)]
pub _ht_tpname: *mut c_char,
#[cfg(Py_3_11)]
pub _spec_cache: _specialization_cache,
}
impl Default for PyHeapTypeObject {

View file

@ -10,6 +10,8 @@ pub struct PyBaseExceptionObject {
pub dict: *mut PyObject,
#[cfg(not(PyPy))]
pub args: *mut PyObject,
#[cfg(all(Py_3_11, not(PyPy)))]
pub notes: *mut PyObject,
#[cfg(not(PyPy))]
pub traceback: *mut PyObject,
#[cfg(not(PyPy))]
@ -27,6 +29,8 @@ pub struct PySyntaxErrorObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
#[cfg(Py_3_11)]
pub notes: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
@ -51,6 +55,8 @@ pub struct PyImportErrorObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
#[cfg(Py_3_11)]
pub notes: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
@ -68,6 +74,8 @@ pub struct PyUnicodeErrorObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
#[cfg(Py_3_11)]
pub notes: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
@ -87,6 +95,8 @@ pub struct PySystemExitObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
#[cfg(Py_3_11)]
pub notes: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
@ -102,6 +112,8 @@ pub struct PyOSErrorObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
#[cfg(Py_3_11)]
pub notes: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
@ -124,6 +136,8 @@ pub struct PyStopIterationObject {
pub dict: *mut PyObject,
#[cfg(not(PyPy))]
pub args: *mut PyObject,
#[cfg(all(Py_3_11, not(PyPy)))]
pub notes: *mut PyObject,
#[cfg(not(PyPy))]
pub traceback: *mut PyObject,
#[cfg(not(PyPy))]

View file

@ -0,0 +1,15 @@
#[cfg(not(PyPy))]
pub struct _PyWeakReference {
pub ob_base: crate::PyObject,
pub wr_object: *mut crate::PyObject,
pub wr_callback: *mut crate::PyObject,
pub hash: crate::Py_hash_t,
pub wr_prev: *mut crate::PyWeakReference,
pub wr_next: *mut crate::PyWeakReference,
#[cfg(Py_3_11)]
pub vectorcall: Option<crate::vectorcallfunc>,
}
// skipped _PyWeakref_GetWeakrefCount
// skipped _PyWeakref_ClearRef
// skipped PyWeakRef_GET_OBJECT

View file

@ -5,14 +5,7 @@ use std::os::raw::c_int;
opaque_struct!(PyWeakReference);
#[cfg(all(not(PyPy), not(Py_LIMITED_API)))]
pub struct PyWeakReference {
pub ob_base: PyObject,
pub wr_object: *mut PyObject,
pub wr_callback: *mut PyObject,
pub hash: crate::Py_hash_t,
pub wr_prev: *mut PyWeakReference,
pub wr_next: *mut PyWeakReference,
}
pub use crate::_PyWeakReference as PyWeakReference;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {