summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_slice.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-04-16 21:47:12 (GMT)
committerBenjamin Peterson <benjamin@python.org>2016-04-16 21:47:12 (GMT)
commit414f8b937f1ccab9a493b387fa42529416ea1a08 (patch)
tree664ee0f250d2e2827260d486987b166645011869 /Lib/test/test_slice.py
parent16b83b1f6672e73a7079bb6655354e506ebb1af2 (diff)
downloadcpython-414f8b937f1ccab9a493b387fa42529416ea1a08.zip
cpython-414f8b937f1ccab9a493b387fa42529416ea1a08.tar.gz
cpython-414f8b937f1ccab9a493b387fa42529416ea1a08.tar.bz2
add gc support to slice (closes #26659)
Diffstat (limited to 'Lib/test/test_slice.py')
-rw-r--r--Lib/test/test_slice.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py
index 68518d7..262ee12 100644
--- a/Lib/test/test_slice.py
+++ b/Lib/test/test_slice.py
@@ -1,8 +1,10 @@
# tests for slice objects; in particular the indices method.
import unittest
-from test import test_support
+import weakref
+
from cPickle import loads, dumps
+from test import test_support
import sys
@@ -128,6 +130,15 @@ class SliceTest(unittest.TestCase):
self.assertEqual(s.indices(15), t.indices(15))
self.assertNotEqual(id(s), id(t))
+ def test_cycle(self):
+ class myobj(): pass
+ o = myobj()
+ o.s = slice(o)
+ w = weakref.ref(o)
+ o = None
+ test_support.gc_collect()
+ self.assertIsNone(w())
+
def test_main():
test_support.run_unittest(SliceTest)