Skip to content
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-39573: Convert Py_TYPE() and Py_SIZE() back to macros #23366

Merged
merged 1 commit into from Nov 18, 2020

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 18, 2020

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

#endif

(Contributed by Dong-hee Na in :issue:`39573`.)

* Since :c:func:`Py_REFCNT()` is changed to the inline static function,
Copy link
Contributor

@hroncok hroncok Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this one.

Copy link
Member Author

@vstinner vstinner Nov 18, 2020

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.

Copy link
Contributor

@hroncok hroncok Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Member Author

@vstinner vstinner Nov 18, 2020

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.

Copy link
Contributor

@hroncok hroncok Nov 18, 2020

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

Copy link
Member Author

@vstinner vstinner Nov 18, 2020

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 ;-)

This change partically reverts
commit ad3252b
and the commit fe2978b.

Many third party C extension modules rely on the ability of using
Py_TYPE() to set an object type: "Py_TYPE(obj) = type;" or to set an
object type using: "Py_SIZE(obj) = size;".
@vstinner vstinner force-pushed the revert_py_type branch 2 times, most recently from 3cd6d4d to 741ed78 Compare Nov 18, 2020
@vstinner vstinner changed the title bpo-39573: Convert Py_TYPE() back to a macro bpo-39573: Convert Py_TYPE() and Py_SIZE() back to macros Nov 18, 2020
@vstinner
Copy link
Member Author

vstinner commented Nov 18, 2020

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.

@vstinner vstinner merged commit 0e2ac21 into python:master Nov 18, 2020
3 checks passed
@vstinner vstinner deleted the revert_py_type branch Nov 18, 2020
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…3366)

This change partically reverts
commit ad3252b
and the commit fe2978b.

Many third party C extension modules rely on the ability of using
Py_TYPE() to set an object type: "Py_TYPE(obj) = type;" or to set an
object type using: "Py_SIZE(obj) = size;".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants