Commit 6a2852cd authored by Fred Drake's avatar Fred Drake

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.
parent 4458ece4
...@@ -624,7 +624,9 @@ PyWeakref_NewRef(PyObject *ob, PyObject *callback) ...@@ -624,7 +624,9 @@ PyWeakref_NewRef(PyObject *ob, PyObject *callback)
} }
list = GET_WEAKREFS_LISTPTR(ob); list = GET_WEAKREFS_LISTPTR(ob);
get_basic_refs(*list, &ref, &proxy); 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 */ /* return existing weak reference if it exists */
result = ref; result = ref;
if (result != NULL) if (result != NULL)
...@@ -664,6 +666,8 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback) ...@@ -664,6 +666,8 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
} }
list = GET_WEAKREFS_LISTPTR(ob); list = GET_WEAKREFS_LISTPTR(ob);
get_basic_refs(*list, &ref, &proxy); get_basic_refs(*list, &ref, &proxy);
if (callback == Py_None)
callback = NULL;
if (callback == NULL) if (callback == NULL)
/* attempt to return an existing weak reference if it exists */ /* attempt to return an existing weak reference if it exists */
result = proxy; result = proxy;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment