-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
gh-120834: fix type of *_iframe field in _PyGenObject_HEAD declaration #120835
Conversation
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
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.
To do this we'll need to either:
Move _PyInterpreterFrame
to a public header
Move _PyGenObject_HEAD
to a private header.
If you can avoid breaking the API, the second option is preferable.
When you're done making the requested changes, leave the comment: |
|
Is the actual structure of |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @mdboom, @markshannon: please review the changes made to this pull request. |
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.
Nice, this will definitely make things more maintainable.
It would be good to get rid of the _PyGenObject_HEAD
macro, but that's for another PR.
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit c9ed63f 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
Do you know the history, why we have three structs with the same structure but different names? |
Probably to avoid copy and pasting the struct for the coroutine classes and keep |
@@ -814,8 +813,7 @@ static PyAsyncMethods gen_as_async = { | |||
PyTypeObject PyGen_Type = { | |||
PyVarObject_HEAD_INIT(&PyType_Type, 0) | |||
"generator", /* tp_name */ | |||
offsetof(PyGenObject, gi_iframe) + | |||
offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */ | |||
sizeof(PyGenObject), /* tp_basicsize */ |
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 think this should be offsetof(PyGenObject, gi_frame.localsplus)
otherwise we are overallocating one PyObject *
slot.
Likewise for PyCoroObject
and PyAsyncGenObject
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.
Let's try that: #120941
But PyGenObject , PyCoroObject and PyAsyncGenObject are the same thing. Why don't we have just one type for all of them? |
They haven't always been the same 299483c |
Instead of copying the implementation of `_PyGen_GetCode` every time it changes in cpython, use the public `PyGen_GetCode` function. The current implementation would break for Python 3.14 as it has been changed upstream in python/cpython#120835.
Fixes #120834 .