[Python-checkins] gh-99051: remove duplicated test from `test_weakref` (GH-99052)
miss-islington
webhook-mailer at python.org
Sun Nov 6 14:50:17 EST 2022
https://github.com/python/cpython/commit/cd6fe9668935dfb38e493f997d19a19797555e88
commit: cd6fe9668935dfb38e493f997d19a19797555e88
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-11-06T11:50:12-08:00
summary:
gh-99051: remove duplicated test from `test_weakref` (GH-99052)
(cherry picked from commit 8463cb55dabb78571e32d8c8c7de8679ab421c2c)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
M Lib/test/test_weakref.py
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index f612e79dca18..478926b5a892 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -595,7 +595,7 @@ class C(object):
# deallocation of c2.
del c2
- def test_callback_in_cycle_1(self):
+ def test_callback_in_cycle(self):
import gc
class J(object):
@@ -635,40 +635,11 @@ def acallback(self, ignore):
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.
@@ -688,10 +659,10 @@ def cb(self, ignore):
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.
More information about the Python-checkins
mailing list