-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-39573: Convert Py_TYPE() and Py_SIZE() back to macros #23366
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
Conversation
#endif | ||
|
||
(Contributed by Dong-hee Na in :issue:`39573`.) | ||
|
||
* Since :c:func:`Py_REFCNT()` is changed to the inline static function, |
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.
Also this one.
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 didn't see any bug report about Py_REFCNT() becoming a static inline function, so I prefer to only change Py_TYPE() and Py_SIZE().
Setting manually the reference counter of an object is a very rare use case. I'm only aware of Cython doing that, and I already updated Cython to use Py_SET_REFCNT() internally.
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.
OK.
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.
Note: I'm open to reverting Py_REFCNT() as well if the Py_REFCNT() change breaks too many third party Python projects.
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.
Ok, I've made a mistake here and I've meant to point out Py_SIZE is not removed. See #23375
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.
Oh sorry, I misunderstood your comment! Thanks for the PR, it's already merged ;-)
I updated my PR to revret not only Py_TYPE(), but also Py_SIZE(). See discussion starting at https://bugs.python.org/issue39573#msg379675 for the rationale of revert these changes. |
This change partically reverts the
commit ad3252b.
Many third party C extension modules rely on the ability of using
Py_TYPE() to set an object type: "Py_TYPE(obj) = type;".
https://bugs.python.org/issue39573