MCPcopy Index your code
hub / github.com/python/cpython / check_free_after_iterating

Function check_free_after_iterating

Lib/test/support/__init__.py:2080–2099  ·  view source on GitHub ↗
(test, iter, cls, args=())

Source from the content-addressed store, hash-verified

2078
2079
2080def check_free_after_iterating(test, iter, cls, args=()):
2081 done = False
2082 def wrapper():
2083 class A(cls):
2084 def __del__(self):
2085 nonlocal done
2086 done = True
2087 try:
2088 next(it)
2089 except StopIteration:
2090 pass
2091
2092 it = iter(A(*args))
2093 # Issue 26494: Shouldn't crash
2094 test.assertRaises(StopIteration, next, it)
2095
2096 wrapper()
2097 # The sequence should be deallocated just after the end of iterating
2098 gc_collect()
2099 test.assertTrue(done)
2100
2101
2102def missing_compiler_executable(cmd_names=[]):

Callers 1

Calls 3

gc_collectFunction · 0.85
assertTrueMethod · 0.80
wrapperFunction · 0.70

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…