]> granicus.if.org Git - python/commitdiff
Fix bug in interpretation of the "callback" argument in the constructors for
authorFred Drake <fdrake@acm.org>
Tue, 3 Feb 2004 19:52:56 +0000 (19:52 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 3 Feb 2004 19:52:56 +0000 (19:52 +0000)
weakref ref and proxy objects; None was not being treated as identical to
NULL, though it was documented as equivalent.

Objects/weakrefobject.c

index db1f8d190659f2230d7a0f41d6e61fdaafb74658..cf0316a50fd943dec296a7ceee117ebb985e56b6 100644 (file)
@@ -624,7 +624,9 @@ PyWeakref_NewRef(PyObject *ob, PyObject *callback)
     }
     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 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
     }
     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;