Skip to content

Commit 0e0e662

Browse files
committed
fix _PyFrameEvalFunction. Since python 3.11 it receives a _PyInterpreterFrame
1 parent 300f2d6 commit 0e0e662

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

newsfragments/3500.fixed.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In Python 3.11 the `_PyFrameEvalFunction` receives a `_PyInterpreterFrame` opaque struct.
2+

pyo3-ffi/src/cpython/ceval.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ use std::os::raw::c_int;
55
extern "C" {
66
// skipped non-limited _PyEval_CallTracing
77

8+
#[cfg(not(Py_3_11))]
89
pub fn _PyEval_EvalFrameDefault(arg1: *mut crate::PyFrameObject, exc: c_int) -> *mut PyObject;
10+
11+
#[cfg(Py_3_11)]
12+
pub fn _PyEval_EvalFrameDefault(
13+
tstate: *mut crate::PyThreadState,
14+
frame: *mut crate::_PyInterpreterFrame,
15+
exc: c_int,
16+
) -> *mut crate::PyObject;
17+
918
pub fn _PyEval_RequestCodeExtraIndex(func: freefunc) -> c_int;
1019
pub fn PyEval_SetProfile(trace_func: Option<Py_tracefunc>, arg1: *mut PyObject);
1120
pub fn PyEval_SetTrace(trace_func: Option<Py_tracefunc>, arg1: *mut PyObject);

pyo3-ffi/src/cpython/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub(crate) mod pystate;
3131
pub(crate) mod pythonrun;
3232
// skipped sysmodule.h
3333
pub(crate) mod floatobject;
34+
#[cfg(not(PyPy))]
35+
pub(crate) mod pyframe;
3436
pub(crate) mod tupleobject;
3537
pub(crate) mod unicodeobject;
3638
pub(crate) mod weakrefobject;
@@ -58,6 +60,8 @@ pub use self::object::*;
5860
pub use self::objimpl::*;
5961
pub use self::pydebug::*;
6062
pub use self::pyerrors::*;
63+
#[cfg(not(PyPy))]
64+
pub use self::pyframe::*;
6165
#[cfg(all(Py_3_8, not(PyPy)))]
6266
pub use self::pylifecycle::*;
6367
pub use self::pymem::*;

pyo3-ffi/src/cpython/pyframe.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[cfg(Py_3_11)]
2+
opaque_struct!(_PyInterpreterFrame);

pyo3-ffi/src/cpython/pystate.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,20 @@ extern "C" {
6969
pub fn PyThreadState_DeleteCurrent();
7070
}
7171

72-
#[cfg(Py_3_9)]
72+
#[cfg(all(Py_3_9, not(Py_3_11)))]
7373
pub type _PyFrameEvalFunction = extern "C" fn(
7474
*mut crate::PyThreadState,
7575
*mut crate::PyFrameObject,
7676
c_int,
7777
) -> *mut crate::object::PyObject;
7878

79+
#[cfg(Py_3_11)]
80+
pub type _PyFrameEvalFunction = extern "C" fn(
81+
*mut crate::PyThreadState,
82+
*mut crate::_PyInterpreterFrame,
83+
c_int,
84+
) -> *mut crate::object::PyObject;
85+
7986
#[cfg(Py_3_9)]
8087
extern "C" {
8188
/// Get the frame evaluation function.

0 commit comments

Comments
 (0)