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.
This commit is contained in:
Fred Drake 2004-02-03 19:52:56 +00:00
parent 4458ece4d7
commit 6a2852cd48
1 changed files with 5 additions and 1 deletions

View 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;