-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
clear_weakref() in Objects/weakrefobject.c is Confusing #95348
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
Comments
I think I will give this a go |
Would there be an issue of this breaking existing code though? EDIT: Ok silly question. It isn't a function that is exported. |
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 1, 2022
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 1, 2022
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 1, 2022
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 5, 2022
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 5, 2022
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 5, 2022
PurityLake
added a commit
to PurityLake/cpython
that referenced
this issue
Aug 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
(inspired by #95302 (comment))
In Objects/weakrefobject.c, the
clear_weakref()
function is used to:PyWeakReference
object off its referenced object'stp_weaklist
(a linked list)However, in the places it is used, it isn't clear what it's doing. When adding a new use of
clear_weakref()
in one of my PRs it was particularly confusing to a reviewer what the relationship was betweenclear_weakref()
and an object's weakref list (i.e.tp_weaklist
).While we could simply rename it to "remove_and_clear_weakref", it may make sense to do the following:
remove_weakref()
that has an explicitPyWeakReference **
parameterclear_weakref()
)remove_weakref_from_referent()
which callsGET_WEAKREFS_LISTPTR(self->wr_object)
and callsremove_weakref()
on itclear_weakref()
Other observations:
self->hash
orself->vectorcall
to NULL inclear_weakref()
PyObject_ClearWeakRefs()
when the weakref doesn't have a callbackThe text was updated successfully, but these errors were encountered: