summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-22 20:31:31 (GMT)
committerGitHub <noreply@github.com>2023-06-22 20:31:31 (GMT)
commit46a3190fcf8580f322047395408cd60feba67041 (patch)
treef7a27fae83831b5ce9109f81506e7c5e5c9757e5 /Objects
parentc38da1e3e19a7bf1053c6d52e730e970efeceff6 (diff)
downloadcpython-46a3190fcf8580f322047395408cd60feba67041.zip
cpython-46a3190fcf8580f322047395408cd60feba67041.tar.gz
cpython-46a3190fcf8580f322047395408cd60feba67041.tar.bz2
gh-105927: Avoid calling PyWeakref_GET_OBJECT() (#105997)
* Replace PyWeakref_GET_OBJECT() with _PyWeakref_GET_REF(). * _sqlite/blob.c now holds a strong reference to the blob object while calling close_blob(). * _xidregistry_find_type() now holds a strong reference to registered while using it.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/weakrefobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 49342d0..c54f663 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -140,7 +140,11 @@ weakref_vectorcall(PyObject *self, PyObject *const *args,
if (!_PyArg_CheckPositional("weakref", nargs, 0, 0)) {
return NULL;
}
- return Py_NewRef(PyWeakref_GET_OBJECT(self));
+ PyObject *obj = _PyWeakref_GET_REF(self);
+ if (obj == NULL) {
+ Py_RETURN_NONE;
+ }
+ return obj;
}
static Py_hash_t