From 6a2852cd48fbe4164c6a6eec95a086e8630dde45 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Tue, 3 Feb 2004 19:52:56 +0000 Subject: [PATCH] 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. --- Objects/weakrefobject.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index db1f8d19065..cf0316a50fd 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;