summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-04-24 21:57:36 +0300
committerGitHub <noreply@github.com>2023-04-24 12:57:36 -0600
commit58b6be3791f55ceb550822ffd8664eca10fd89c4 (patch)
tree5bbe8d2c68d3227b33a1b81f1bef6a13b766aed4 /Objects
parent2aa22f72fbbabb4ca2a641c0546d25c45128c56f (diff)
downloadcpython-git-58b6be3791f55ceb550822ffd8664eca10fd89c4.tar.gz
gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (#99244)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/weakrefobject.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 5a3e49a6fe..c1afe63ecf 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -170,10 +170,7 @@ weakref_repr(PyWeakReference *self)
}
Py_INCREF(obj);
- if (_PyObject_LookupAttr(obj, &_Py_ID(__name__), &name) < 0) {
- Py_DECREF(obj);
- return NULL;
- }
+ name = _PyObject_LookupSpecial(obj, &_Py_ID(__name__));
if (name == NULL || !PyUnicode_Check(name)) {
repr = PyUnicode_FromFormat(
"<weakref at %p; to '%s' at %p>",