◐ Shell
clean mode source ↗

bpo-44032: Move pointer to code object from frame-object to frame specials array. by markshannon · Pull Request #26771 · python/cpython

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)