Fix bug in interpretation of the "callback" argument in the constructors for
weakref ref and proxy objects; None was not being treated as identical to
NULL, though it was documented as equivalent.
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index db1f8d1..cf0316a 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -624,7 +624,9 @@
}
list = GET_WEAKREFS_LISTPTR(ob);
get_basic_refs(*list, &ref, &proxy);
- if (callback == NULL || callback == Py_None)
+ if (callback == Py_None)
+ callback = NULL;
+ if (callback == NULL)
/* return existing weak reference if it exists */
result = ref;
if (result != NULL)
@@ -664,6 +666,8 @@
}
list = GET_WEAKREFS_LISTPTR(ob);
get_basic_refs(*list, &ref, &proxy);
+ if (callback == Py_None)
+ callback = NULL;
if (callback == NULL)
/* attempt to return an existing weak reference if it exists */
result = proxy;