summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2022-11-06 19:28:44 (GMT)
committerGitHub <noreply@github.com>2022-11-06 19:28:44 (GMT)
commit8463cb55dabb78571e32d8c8c7de8679ab421c2c (patch)
tree8e2e4d5b1c15a450b235551c81476571bae1ee1d /Lib/test
parent7dcd28eb41abeb29ddefd0a49fa9f7a9ebd61e16 (diff)
downloadcpython-8463cb55dabb78571e32d8c8c7de8679ab421c2c.zip
cpython-8463cb55dabb78571e32d8c8c7de8679ab421c2c.tar.gz
cpython-8463cb55dabb78571e32d8c8c7de8679ab421c2c.tar.bz2
gh-99051: remove duplicated test from `test_weakref` (GH-99052)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_weakref.py41
1 files changed, 6 insertions, 35 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 3a9573d..7c59207 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -597,7 +597,7 @@ class ReferencesTestCase(TestBase):
# deallocation of c2.
del c2
- def test_callback_in_cycle_1(self):
+ def test_callback_in_cycle(self):
import gc
class J(object):
@@ -637,40 +637,11 @@ class ReferencesTestCase(TestBase):
del I, J, II
gc.collect()
- def test_callback_in_cycle_2(self):
+ def test_callback_reachable_one_way(self):
import gc
- # This is just like test_callback_in_cycle_1, except that II is an
- # old-style class. The symptom is different then: an instance of an
- # old-style class looks in its own __dict__ first. 'J' happens to
- # get cleared from I.__dict__ before 'wr', and 'J' was never in II's
- # __dict__, so the attribute isn't found. The difference is that
- # the old-style II doesn't have a NULL __mro__ (it doesn't have any
- # __mro__), so no segfault occurs. Instead it got:
- # test_callback_in_cycle_2 (__main__.ReferencesTestCase) ...
- # Exception exceptions.AttributeError:
- # "II instance has no attribute 'J'" in <bound method II.acallback
- # of <?.II instance at 0x00B9B4B8>> ignored
-
- class J(object):
- pass
-
- class II:
- def acallback(self, ignore):
- self.J
-
- I = II()
- I.J = J
- I.wr = weakref.ref(J, I.acallback)
-
- del I, J, II
- gc.collect()
-
- def test_callback_in_cycle_3(self):
- import gc
-
- # This one broke the first patch that fixed the last two. In this
- # case, the objects reachable from the callback aren't also reachable
+ # This one broke the first patch that fixed the previous test. In this case,
+ # the objects reachable from the callback aren't also reachable
# from the object (c1) *triggering* the callback: you can get to
# c1 from c2, but not vice-versa. The result was that c2's __dict__
# got tp_clear'ed by the time the c2.cb callback got invoked.
@@ -690,10 +661,10 @@ class ReferencesTestCase(TestBase):
del c1, c2
gc.collect()
- def test_callback_in_cycle_4(self):
+ def test_callback_different_classes(self):
import gc
- # Like test_callback_in_cycle_3, except c2 and c1 have different
+ # Like test_callback_reachable_one_way, except c2 and c1 have different
# classes. c2's class (C) isn't reachable from c1 then, so protecting
# objects reachable from the dying object (c1) isn't enough to stop
# c2's class (C) from getting tp_clear'ed before c2.cb is invoked.