bpo-44032: Move pointer to code object from frame-object to frame specials array.#26771
Conversation
|
Skipping news as this is just making |
ericsnowcurrently
left a comment
There was a problem hiding this comment.
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.
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_codefield 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