You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PyWeakref_GET_OBJECT() and PyWeakref_GetObject() return a borrowed reference to the object, or a borrowed reference to None if the object has been finalized. This API is error-prone and not easy to use.
No error is set. See PR #105929 for the first part of the implementation.
Would it be better to return None if the object has been finalized? The idiom is that APIs returning a PyObject pointer only will return NULL in case of error.
Activity
erlend-aasland commentedon Jun 19, 2023
With an error set? If no, would you need to call
PyErr_Occurred()to find out if an error has occurred? See also capi-workgroup/problems#1pythongh-105927: Refactor weakrefobject.c
pythongh-105927: Refactor weakrefobject.c
pythongh-105927: Refactor weakrefobject.c
pythongh-105927: Refactor weakrefobject.c
pythongh-105927: Refactor weakrefobject.c
gh-105927: Refactor weakrefobject.c (#105928)
pythongh-105927: Add _PyWeakref_GET_REF() internal function
vstinner commentedon Jun 20, 2023
No error is set. See PR #105929 for the first part of the implementation.
gh-105927: Add _PyWeakref_GET_REF() internal function (#105929)
pythongh-105927: Add PyWeakref_GetRef() function
pythongh-105927: Add PyWeakref_GetRef() function
erlend-aasland commentedon Jun 20, 2023
Would it be better to return None if the object has been finalized? The idiom is that APIs returning a
PyObjectpointer only will returnNULLin case of error.45 remaining items
pythongh-105927: Deprecate PyWeakref_GetObject() function
pythongh-105927: finalize_modules_clear_weaklist() uses _PyWeakref_GE…
gh-105927: Deprecate PyWeakref_GetObject() function (#106006)
pythongh-106104: Use public weakref APIs in sqlite3
vstinner commentedon Jun 27, 2023
Oh, PEP 703 – Making the Global Interpreter Lock Optional in CPython proposes PyWeakref_FetchObject() which is more or less the PyWeakref_GetRef() function that was just added to Python 3.13.
vstinner commentedon Jun 30, 2023
I added
PyWeakref_GetRef()functions and deprecated PyWeakref_GetObject() and PyWeakref_GET_OBJECT() functions. I close the issue.pythongh-105927: PyWeakref_GetRef() returns 1 on success
gh-105927: PyWeakref_GetRef() returns 1 on success (#106561)
pythongh-105927: Limit PyWeakref_GetRef() to limited C API 3.13
gh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (#117091)
pythongh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (pyth…
Squashed commit of the following:
Squashed commit of the following:
pythongh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (pyth…