summaryrefslogtreecommitdiffstats
path: root/Objects/weakrefobject.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-04-24 19:58:55 (GMT)
committerGitHub <noreply@github.com>2023-04-24 19:58:55 (GMT)
commitc8de883bcb022b59d7ae6d20993599b47e4b968b (patch)
treeae49f539621a792b3de515503395b2896752a9d2 /Objects/weakrefobject.c
parenta8489f7f264ec34601c48e0996810d96e0ec2464 (diff)
downloadcpython-c8de883bcb022b59d7ae6d20993599b47e4b968b.zip
cpython-c8de883bcb022b59d7ae6d20993599b47e4b968b.tar.gz
cpython-c8de883bcb022b59d7ae6d20993599b47e4b968b.tar.bz2
[3.11] gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (GH-99244) (#103789)
gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (GH-99244) (cherry picked from commit 58b6be3791f55ceb550822ffd8664eca10fd89c4) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r--Objects/weakrefobject.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index d26fc9e..c76c928 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>",