Skip to content

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