mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[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 58b6be3791
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
a8489f7f26
commit
c8de883bcb
3 changed files with 14 additions and 4 deletions
|
@ -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>",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue