-
Notifications
You must be signed in to change notification settings - Fork 956
Frame ffi #5154
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
Merged
+79
−57
Merged
Frame ffi #5154
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3518db4
add missing pyframe ffi functions
dsal3389 5a29afe
Rearrange pyframe stuff to match CPython structure
codeguru42 53f3fa1
Remove duplicate declaration
codeguru42 9b49578
Clean up duplicate declaration of PyFrameObject
codeguru42 9f738b9
Fix imports
codeguru42 4c51ab1
Update changelog
codeguru42 e8baac7
Conditional compilation for `use` statement that matches its usage
codeguru42 9544287
Match `use` conditional compilation with usage
codeguru42 8677dba
Fix another `use` statement
codeguru42 ba1c6ae
Don't need cfg_attr()
codeguru42 eb5abcc
Fix another conditional compilation
codeguru42 0797a92
Conditional compilation for `use`
codeguru42 0a4876e
Another conditional compile
codeguru42 72137fc
More conditional compile checks
codeguru42 e4b34f6
One more
codeguru42 d80a25a
Remove unused import
codeguru42 aa953a6
Changelog for removed items
codeguru42 cddf8fd
Remove unnecessary wording in comments
codeguru42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| * added missing ffi functions for `PyFrameObject` but without | ||
| including unstable API from python 3.13 | ||
| * moved ffi functions to correct files to mach CPython as of 3.13 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Removed access to internals of PyFrameObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,62 @@ | ||
| #[cfg(any(Py_3_11, all(Py_3_9, not(PyPy))))] | ||
| use crate::PyFrameObject; | ||
| use crate::{PyObject, PyTypeObject, Py_TYPE}; | ||
| #[cfg(Py_3_12)] | ||
| use std::os::raw::c_char; | ||
| use std::os::raw::c_int; | ||
| use std::ptr::addr_of_mut; | ||
|
|
||
| // NB used in `_PyEval_EvalFrameDefault`, maybe we remove this too. | ||
| #[cfg(all(Py_3_11, not(PyPy)))] | ||
| opaque_struct!(pub _PyInterpreterFrame); | ||
|
|
||
| #[cfg_attr(windows, link(name = "pythonXY"))] | ||
| extern "C" { | ||
| pub static mut PyFrame_Type: PyTypeObject; | ||
|
|
||
| #[cfg(Py_3_13)] | ||
| pub static mut PyFrameLocalsProxy_Type: PyTypeObject; | ||
| } | ||
|
|
||
| #[inline] | ||
| pub unsafe fn PyFrame_Check(op: *mut PyObject) -> c_int { | ||
| (Py_TYPE(op) == addr_of_mut!(PyFrame_Type)) as c_int | ||
| } | ||
|
|
||
| #[cfg(Py_3_13)] | ||
| #[inline] | ||
| pub unsafe fn PyFrameLocalsProxy_Check(op: *mut PyObject) -> c_int { | ||
| (Py_TYPE(op) == addr_of_mut!(PyFrameLocalsProxy_Type)) as c_int | ||
| } | ||
|
|
||
| extern "C" { | ||
| #[cfg(all(Py_3_9, not(PyPy)))] | ||
| pub fn PyFrame_GetBack(frame: *mut PyFrameObject) -> *mut PyFrameObject; | ||
|
|
||
| #[cfg(Py_3_11)] | ||
| pub fn PyFrame_GetLocals(frame: *mut PyFrameObject) -> *mut PyObject; | ||
|
|
||
| #[cfg(Py_3_11)] | ||
| pub fn PyFrame_GetGlobals(frame: *mut PyFrameObject) -> *mut PyObject; | ||
|
|
||
| #[cfg(Py_3_11)] | ||
| pub fn PyFrame_GetBuiltins(frame: *mut PyFrameObject) -> *mut PyObject; | ||
|
|
||
| #[cfg(Py_3_11)] | ||
| pub fn PyFrame_GetGenerator(frame: *mut PyFrameObject) -> *mut PyObject; | ||
|
|
||
| #[cfg(Py_3_11)] | ||
| pub fn PyFrame_GetLasti(frame: *mut PyFrameObject) -> c_int; | ||
|
|
||
| #[cfg(Py_3_12)] | ||
| pub fn PyFrame_GetVar(frame: *mut PyFrameObject, name: *mut PyObject) -> *mut PyObject; | ||
|
|
||
| #[cfg(Py_3_12)] | ||
| pub fn PyFrame_GetVarString(frame: *mut PyFrameObject, name: *mut c_char) -> *mut PyObject; | ||
|
|
||
| // skipped PyUnstable_InterpreterFrame_GetCode | ||
| // skipped PyUnstable_InterpreterFrame_GetLasti | ||
| // skipped PyUnstable_InterpreterFrame_GetLine | ||
| // skipped PyUnstable_ExecutableKinds | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,15 @@ | ||
| #[allow(unused_imports)] | ||
| use crate::object::PyObject; | ||
| #[cfg(not(GraalPy))] | ||
| #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] | ||
| use crate::PyCodeObject; | ||
| #[cfg(not(Py_LIMITED_API))] | ||
| use crate::PyFrameObject; | ||
| use std::os::raw::c_int; | ||
|
|
||
| #[cfg(Py_LIMITED_API)] | ||
| opaque_struct!(pub PyFrameObject); | ||
|
|
||
| extern "C" { | ||
| pub fn PyFrame_GetLineNumber(f: *mut PyFrameObject) -> c_int; | ||
| pub fn PyFrame_GetLineNumber(frame: *mut PyFrameObject) -> c_int; | ||
|
|
||
| #[cfg(not(GraalPy))] | ||
| #[cfg(any(Py_3_10, all(Py_3_9, not(Py_LIMITED_API))))] | ||
| pub fn PyFrame_GetCode(f: *mut PyFrameObject) -> *mut PyCodeObject; | ||
| pub fn PyFrame_GetCode(frame: *mut PyFrameObject) -> *mut PyCodeObject; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // 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 | ||
|
Comment on lines
+1
to
+2
Member
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. 👍 |
||
|
|
||
| opaque_struct!(pub PyFrameObject); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a
5154.removed.mdto note that we no longer offer access to the frame object internal structure on versions before 3.11.