mirror of https://github.com/python/cpython
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:
parent
4458ece4d7
commit
6a2852cd48
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue