Skip to content

bpo-46417: PyWeakref_GET_OBJECT() uses PyWeakref_CheckRef() #30763

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

Closed
wants to merge 1 commit into from
Closed

bpo-46417: PyWeakref_GET_OBJECT() uses PyWeakref_CheckRef() #30763

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jan 21, 2022

PyWeakref_GET_OBJECT() now ensures that the its argument is valid
using PyWeakref_CheckRef().

  • Convert PyWeakref_GET_OBJECT() macro to a static inline function.
  • Remove now redundant assert(PyWeakref_CheckRef(ref)) before
    PyWeakref_GET_OBJECT(ref) calls.
  • Add proxy_get_object() to proxy functions.
  • _ctypes PyDict_GetItemProxy() uses the private
    _PyWeakref_GET_OBJECT() function.
  • Cleanup weakrefobject.c.

https://bugs.python.org/issue46417

PyWeakref_GET_OBJECT() now ensures that the its argument is valid
using PyWeakref_CheckRef().

* Convert PyWeakref_GET_OBJECT() macro to a static inline function.
* Remove now redundant assert(PyWeakref_CheckRef(ref)) before
  PyWeakref_GET_OBJECT(ref) calls.
* Add proxy_get_object() to proxy functions.
* _ctypes PyDict_GetItemProxy() uses the private
  _PyWeakref_GET_OBJECT() function.
* Cleanup weakrefobject.c.
@vstinner
Copy link
Member Author

I'm not sure if it's allowed to call PyWeakref_GET_OBJECT() on a proxy reference. My change prevents to do that.

In case of doubt, I prefer to abandon my PR. I don't want to take the risk of introducing a backward incompatible change by mistake :-(

@vstinner vstinner closed this Jan 22, 2022
@vstinner vstinner deleted the weakref_get_object branch January 22, 2022 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants