From 1e73ef67f230a36e6f51a973930858c1b606bd40 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 14 Aug 2022 14:23:24 +0100 Subject: [PATCH] ffi: fixes to 3.11 bindings --- pyo3-ffi/src/cpython/genobject.rs | 15 +++++++++++++++ pyo3-ffi/src/cpython/pystate.rs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/pyo3-ffi/src/cpython/genobject.rs b/pyo3-ffi/src/cpython/genobject.rs index 4d494be3..6b522bf8 100644 --- a/pyo3-ffi/src/cpython/genobject.rs +++ b/pyo3-ffi/src/cpython/genobject.rs @@ -2,6 +2,8 @@ use crate::object::*; use crate::PyFrameObject; #[cfg(not(PyPy))] use crate::_PyErr_StackItem; +#[cfg(Py_3_11)] +use std::os::raw::c_char; use std::os::raw::c_int; #[cfg(not(PyPy))] @@ -9,6 +11,7 @@ use std::os::raw::c_int; #[derive(Copy, Clone)] pub struct PyGenObject { pub ob_base: PyObject, + #[cfg(not(Py_3_11))] pub gi_frame: *mut PyFrameObject, #[cfg(not(Py_3_10))] pub gi_running: c_int, @@ -17,6 +20,18 @@ pub struct PyGenObject { pub gi_name: *mut PyObject, pub gi_qualname: *mut PyObject, pub gi_exc_state: _PyErr_StackItem, + #[cfg(Py_3_11)] + pub gi_origin_or_finalizer: *mut PyObject, + #[cfg(Py_3_11)] + pub gi_hooks_inited: c_char, + #[cfg(Py_3_11)] + pub gi_closed: c_char, + #[cfg(Py_3_11)] + pub gi_running_async: c_char, + #[cfg(Py_3_11)] + pub gi_frame_state: i8, + #[cfg(Py_3_11)] + pub gi_iframe: [*mut PyObject; 1], } #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/pyo3-ffi/src/cpython/pystate.rs b/pyo3-ffi/src/cpython/pystate.rs index 2dcd6958..a70af8e8 100644 --- a/pyo3-ffi/src/cpython/pystate.rs +++ b/pyo3-ffi/src/cpython/pystate.rs @@ -31,8 +31,10 @@ pub const PyTrace_OPCODE: c_int = 7; #[repr(C)] #[derive(Clone, Copy)] pub struct _PyErr_StackItem { + #[cfg(not(Py_3_11))] pub exc_type: *mut PyObject, pub exc_value: *mut PyObject, + #[cfg(not(Py_3_11))] pub exc_traceback: *mut PyObject, pub previous_item: *mut _PyErr_StackItem, }