summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
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 /Lib/test/test_weakref.py
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 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 7c59207..1bc1d05 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -116,6 +116,17 @@ class ReferencesTestCase(TestBase):
del o
repr(wr)
+ def test_repr_failure_gh99184(self):
+ class MyConfig(dict):
+ def __getattr__(self, x):
+ return self[x]
+
+ obj = MyConfig(offset=5)
+ obj_weakref = weakref.ref(obj)
+
+ self.assertIn('MyConfig', repr(obj_weakref))
+ self.assertIn('MyConfig', str(obj_weakref))
+
def test_basic_callback(self):
self.check_basic_callback(C)
self.check_basic_callback(create_function)