-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
bpo-44032: Move pointer to code object from frame-object to frame specials array. #26771
Conversation
Skipping news as this is just making |
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.
LGTM
I left one minor suggestion for simplifying the GDB tooling. Otherwise this looks ready to go.
Tools/gdb/libpython.py
Outdated
f_valuestack = self.field('f_valuestack') | ||
code = f_valuestack[FRAME_SPECIALS_CODE_OFFSET - FRAME_SPECIALS_SIZE] | ||
return PyCodeObjectPtr.from_pyobject_ptr(code) |
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.
I suppose it doesn't matter much but it's too bad you can't use self._f_specials()
here. With a small adjustment to _f_specials()
this code becomes simpler and more uniform.
For example, let the caller pass the wrapper to use (and default to PyObjectPtr
):
f_valuestack = self.field('f_valuestack') | |
code = f_valuestack[FRAME_SPECIALS_CODE_OFFSET - FRAME_SPECIALS_SIZE] | |
return PyCodeObjectPtr.from_pyobject_ptr(code) | |
return self._f_specials(FRAME_SPECIALS_CODE_OFFSET, PyCodeObjectPtr) |
...or let _f_specials()
decide based on the index (since this code is already so specific and tightly coupled):
f_valuestack = self.field('f_valuestack') | |
code = f_valuestack[FRAME_SPECIALS_CODE_OFFSET - FRAME_SPECIALS_SIZE] | |
return PyCodeObjectPtr.from_pyobject_ptr(code) | |
return self._f_specials(FRAME_SPECIALS_CODE_OFFSET) |
I'm confused about how I'm meant to access the code for a frame now? The struct member is gone, and the accessor function has a leading underscore. Is there a supported way to get to the code for a frame? |
Oh, sorry, PyFrame_GetCode, got it :) |
The
f_code
field is the last field in the frame object that cannot be lazily evaluated if we want to lazily create frame objects, or ignore them in the interpreter.https://bugs.python.org/issue44032