Debian Codegraph @

pypy/module/bz2/test/support.py

raw symbols SCIP
1 class CheckAllocation:
2 def teardown_method(self, fun):
3 from rpython.rtyper.lltypesystem import ll2ctypes
4 import gc
5 tries = 20
6 # remove the GC strings from ll2ctypes
7 for key, value in ll2ctypes.ALLOCATED.items():
8 if value._TYPE._gckind == 'gc':
9 del ll2ctypes.ALLOCATED[key]
10 else:
11 try:
12 tag = value._TYPE.tag
13 except AttributeError:
14 pass
15 else:
16 if 'RPyOpaque_ThreadLock' in tag:
17 del ll2ctypes.ALLOCATED[key]
18 #
19 while tries and ll2ctypes.ALLOCATED:
20 gc.collect() # to make sure we disallocate buffers
21 self.space.getexecutioncontext()._run_finalizers_now()
22 tries -= 1
23 assert not ll2ctypes.ALLOCATED