diff options
author | Fred Drake <fdrake@acm.org> | 2004-02-03 19:52:56 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-02-03 19:52:56 (GMT) |
commit | 6a2852cd48fbe4164c6a6eec95a086e8630dde45 (patch) | |
tree | ba61adc4af5676baf95cfb43fc47a7863e40edc7 /Objects/weakrefobject.c | |
parent | 4458ece4d7661ff3c76aea044779b7d235774cbb (diff) | |
download | cpython-6a2852cd48fbe4164c6a6eec95a086e8630dde45.zip cpython-6a2852cd48fbe4164c6a6eec95a086e8630dde45.tar.gz cpython-6a2852cd48fbe4164c6a6eec95a086e8630dde45.tar.bz2 |
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.
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r-- | Objects/weakrefobject.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 @@ 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; |