summaryrefslogtreecommitdiff
path: root/Lib/test/test_weakref.py
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 /Lib/test/test_weakref.py
parent2aa22f72fbbabb4ca2a641c0546d25c45128c56f (diff)
downloadcpython-git-58b6be3791f55ceb550822ffd8664eca10fd89c4.tar.gz
gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (#99244)
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 7c5920797d..1bc1d05f7d 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)