mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue