summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2015-04-13 18:10:06 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2015-04-13 18:10:06 (GMT)
commita63cc212348e276c8ede32773313c60ff7fda651 (patch)
treec47fdcc44d220ed930f465a3fb4f7303ba461742 /Lib/test
parent56452eea39baa9d1864b2275b9e93cf37378af09 (diff)
downloadcpython-a63cc212348e276c8ede32773313c60ff7fda651.zip
cpython-a63cc212348e276c8ede32773313c60ff7fda651.tar.gz
cpython-a63cc212348e276c8ede32773313c60ff7fda651.tar.bz2
Issue #23726: Don't enable GC for user subclasses of non-GC types that don't add any new fields.
Patch by Eugene Toder.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py2
-rw-r--r--Lib/test/test_gc.py20
2 files changed, 20 insertions, 2 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index cdaae0a..9f3d34d 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3020,8 +3020,6 @@ order (MRO) for bases """
cant(object(), list)
cant(list(), object)
class Int(int): __slots__ = []
- cant(2, Int)
- cant(Int(), int)
cant(True, int)
cant(2, bool)
o = object()
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 2ac1d4b..254f64b 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -546,11 +546,31 @@ class GCTests(unittest.TestCase):
class UserClass:
pass
+
+ class UserInt(int):
+ pass
+
+ # Base class is object; no extra fields.
+ class UserClassSlots:
+ __slots__ = ()
+
+ # Base class is fixed size larger than object; no extra fields.
+ class UserFloatSlots(float):
+ __slots__ = ()
+
+ # Base class is variable size; no extra fields.
+ class UserIntSlots(int):
+ __slots__ = ()
+
self.assertTrue(gc.is_tracked(gc))
self.assertTrue(gc.is_tracked(UserClass))
self.assertTrue(gc.is_tracked(UserClass()))
+ self.assertTrue(gc.is_tracked(UserInt()))
self.assertTrue(gc.is_tracked([]))
self.assertTrue(gc.is_tracked(set()))
+ self.assertFalse(gc.is_tracked(UserClassSlots()))
+ self.assertFalse(gc.is_tracked(UserFloatSlots()))
+ self.assertFalse(gc.is_tracked(UserIntSlots()))
def test_bug1055820b(self):
# Corresponds to temp2b.py in the bug report.