Skip to content

Commit

Permalink
Undo change
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Mar 14, 2024
1 parent eb7f65d commit e7dda6b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Objects/weakrefobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,17 @@ PyWeakref_NewRef(PyObject *ob, PyObject *callback)
*/
result = new_weakref(ob, callback);
if (result != NULL) {
get_basic_refs(*list, &ref, &proxy);
if (callback == NULL) {
if (ref == NULL)
insert_head(result, list);
else {
/* Someone else added a ref without a callback
during GC. Return that one instead of this one
to avoid violating the invariants of the list
of weakrefs for ob. */
Py_SETREF(result, (PyWeakReference*)Py_NewRef(ref));
}
}
else {
PyWeakReference *prev;
Expand Down

0 comments on commit e7dda6b

Please sign in to comment.