summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-04-24 18:57:36 (GMT)
committerGitHub <noreply@github.com>2023-04-24 18:57:36 (GMT)
commit58b6be3791f55ceb550822ffd8664eca10fd89c4 (patch)
tree5bbe8d2c68d3227b33a1b81f1bef6a13b766aed4 /Objects
parent2aa22f72fbbabb4ca2a641c0546d25c45128c56f (diff)
downloadcpython-58b6be3791f55ceb550822ffd8664eca10fd89c4.zip
cpython-58b6be3791f55ceb550822ffd8664eca10fd89c4.tar.gz
cpython-58b6be3791f55ceb550822ffd8664eca10fd89c4.tar.bz2
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 5a3e49a..c1afe63 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>",