-
Notifications
You must be signed in to change notification settings - Fork 933
sync pystate.h headers with Python 3.14
#5711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ddc7edb
b1650e0
0996957
530aec6
441ac3c
151ff09
61bdd96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add FFI definitions `PyThreadState_GetInterpreter` and `PyThreadState_GetID` on Python 3.9+, `PyThreadState_EnterTracing` and `PyThreadState_LeaveTracing` on Python 3.11+, `PyThreadState_GetUnchecked` on Python 3.13+, and `compat::PyThreadState_GetUnchecked`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Correct FFI definition for `PyThreadState_GetFrame` to mark it available with abi3 in 3.10+. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Remove private FFI definitions `_PyFrameEvalFunction`, `_PyInterpreterState_GetEvalFrameFunc` and `_PyInterpreterState_SetEvalFrameFunc`. |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,9 @@ | ||
| #[cfg(not(PyPy))] | ||
| use crate::PyThreadState; | ||
| use crate::{PyFrameObject, PyInterpreterState, PyObject}; | ||
| use std::ffi::c_int; | ||
|
|
||
| // skipped _PyInterpreterState_RequiresIDRef | ||
| // skipped _PyInterpreterState_RequireIDRef | ||
|
|
||
| // skipped _PyInterpreterState_GetMainModule | ||
| // skipped private _PyInterpreterState_RequiresIDRef | ||
| // skipped private _PyInterpreterState_RequireIDRef | ||
|
|
||
| pub type Py_tracefunc = unsafe extern "C" fn( | ||
| obj: *mut PyObject, | ||
|
|
@@ -24,11 +21,14 @@ pub const PyTrace_C_EXCEPTION: c_int = 5; | |
| pub const PyTrace_C_RETURN: c_int = 6; | ||
| pub const PyTrace_OPCODE: c_int = 7; | ||
|
|
||
| // skipped PyTraceInfo | ||
| // skipped CFrame | ||
| // skipped private _Py_MAX_SCRIPT_PATH_SIZE | ||
| // skipped private _PyRemoteDebuggerSupport | ||
|
|
||
| /// Private structure used inline in `PyGenObject` | ||
| #[cfg(not(PyPy))] | ||
| /// | ||
| /// `PyGenObject` was made opaque in Python 3.14, so we don't bother defining this | ||
| /// structure for that version and later. | ||
| #[cfg(not(any(PyPy, Py_3_14)))] | ||
| #[repr(C)] | ||
| #[derive(Clone, Copy)] | ||
| pub(crate) struct _PyErr_StackItem { | ||
|
|
@@ -40,20 +40,30 @@ pub(crate) struct _PyErr_StackItem { | |
| previous_item: *mut _PyErr_StackItem, | ||
| } | ||
|
|
||
| // skipped _PyStackChunk | ||
| // skipped _ts (aka PyThreadState) | ||
| // skipped private _PyStackChunk | ||
|
|
||
| // skipped private _PY_DATA_STACK_CHUNK_SIZE | ||
| // skipped private _ts (aka PyThreadState) | ||
|
|
||
| extern "C" { | ||
| // skipped _PyThreadState_Prealloc | ||
| // skipped _PyThreadState_UncheckedGet | ||
| // skipped _PyThreadState_GetDict | ||
| #[cfg(Py_3_13)] | ||
| pub fn PyThreadState_GetUnchecked() -> *mut PyThreadState; | ||
|
|
||
| #[cfg(not(Py_3_13))] | ||
| pub(crate) fn _PyThreadState_UncheckedGet() -> *mut PyThreadState; | ||
|
|
||
| #[cfg(Py_3_11)] | ||
| pub fn PyThreadState_EnterTracing(state: *mut PyThreadState); | ||
| #[cfg(Py_3_11)] | ||
| pub fn PyThreadState_LeaveTracing(state: *mut PyThreadState); | ||
|
|
||
| #[cfg_attr(PyPy, link_name = "PyPyGILState_Check")] | ||
| pub fn PyGILState_Check() -> c_int; | ||
|
|
||
| // skipped _PyGILState_GetInterpreterStateUnsafe | ||
| // skipped _PyThread_CurrentFrames | ||
| // skipped _PyThread_CurrentExceptions | ||
| // skipped private _PyThread_CurrentFrames | ||
|
|
||
| // skipped PyUnstable_ThreadState_SetStackProtection | ||
| // skipped PyUnstable_ThreadState_ResetStackProtection | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here - seems reasonable to expose these to me.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this one I am going to skip for now, just because "unstable" APIs seem to imply they're more likely to have churn so I'm tempted to wait to take on the maintenance burden until someone asks to use these. |
||
|
|
||
| #[cfg(not(PyPy))] | ||
| pub fn PyInterpreterState_Main() -> *mut PyInterpreterState; | ||
|
|
@@ -70,44 +80,6 @@ extern "C" { | |
| pub fn PyThreadState_DeleteCurrent(); | ||
| } | ||
|
|
||
| #[cfg(all(Py_3_9, not(any(Py_3_11, PyPy))))] | ||
| pub type _PyFrameEvalFunction = extern "C" fn( | ||
| *mut crate::PyThreadState, | ||
davidhewitt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| *mut crate::PyFrameObject, | ||
| c_int, | ||
| ) -> *mut crate::object::PyObject; | ||
|
|
||
| #[cfg(all(Py_3_11, not(PyPy)))] | ||
| pub type _PyFrameEvalFunction = extern "C" fn( | ||
| *mut crate::PyThreadState, | ||
| *mut crate::_PyInterpreterFrame, | ||
| c_int, | ||
| ) -> *mut crate::object::PyObject; | ||
|
|
||
| #[cfg(all(Py_3_9, not(PyPy)))] | ||
| extern "C" { | ||
| /// Get the frame evaluation function. | ||
| pub fn _PyInterpreterState_GetEvalFrameFunc( | ||
| interp: *mut PyInterpreterState, | ||
| ) -> _PyFrameEvalFunction; | ||
|
|
||
| ///Set the frame evaluation function. | ||
| pub fn _PyInterpreterState_SetEvalFrameFunc( | ||
| interp: *mut PyInterpreterState, | ||
| eval_frame: _PyFrameEvalFunction, | ||
| ); | ||
| } | ||
|
|
||
| // skipped _PyInterpreterState_GetConfig | ||
| // skipped _PyInterpreterState_GetConfigCopy | ||
| // skipped _PyInterpreterState_SetConfig | ||
| // skipped _Py_GetConfig | ||
|
|
||
| // skipped _PyCrossInterpreterData | ||
| // skipped _PyObject_GetCrossInterpreterData | ||
| // skipped _PyCrossInterpreterData_NewObject | ||
| // skipped _PyCrossInterpreterData_Release | ||
| // skipped _PyObject_CheckCrossInterpreterData | ||
| // skipped crossinterpdatafunc | ||
| // skipped _PyCrossInterpreterData_RegisterClass | ||
| // skipped _PyCrossInterpreterData_Lookup | ||
| // skipped private _PyFrameEvalFunction | ||
| // skipped private _PyInterpreterState_GetEvalFrameFunc | ||
| // skipped private _PyInterpreterState_SetEvalFrameFunc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,17 @@ | ||
| // TODO: Created this file as part of fixing pyframe.rs and cpython/pyframe.rs | ||
| // TODO: Finish defining or moving declarations now in Include/pytypedefs.h | ||
| // NB: unlike C, we do not need to forward declare structs in Rust. | ||
| // So we only define opaque structs for those which do not have public structure. | ||
|
|
||
| // PyModuleDef | ||
| // PyModuleDef_Slot | ||
| // PyMethodDef | ||
| // PyGetSetDef | ||
| // PyMemberDef | ||
|
|
||
| // PyObject | ||
| // PyLongObject | ||
| // PyTypeObject | ||
| opaque_struct!(pub PyCodeObject); | ||
| opaque_struct!(pub PyFrameObject); | ||
|
|
||
| opaque_struct!(pub PyThreadState); | ||
| opaque_struct!(pub PyInterpreterState); |
Uh oh!
There was an error while loading. Please reload this page.