mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
add gc support to slice (closes #26659)
This commit is contained in:
parent
a07ab29a79
commit
2b601d3905
3 changed files with 31 additions and 7 deletions
|
|
@ -1,11 +1,13 @@
|
|||
# tests for slice objects; in particular the indices method.
|
||||
|
||||
import unittest
|
||||
from pickle import loads, dumps
|
||||
|
||||
import itertools
|
||||
import operator
|
||||
import sys
|
||||
import unittest
|
||||
import weakref
|
||||
|
||||
from pickle import loads, dumps
|
||||
from test import support
|
||||
|
||||
|
||||
def evaluate_slice_index(arg):
|
||||
|
|
@ -240,5 +242,14 @@ 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())
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue