MCPcopy Index your code
hub / github.com/RustPython/RustPython / dash_R_cleanup

Function dash_R_cleanup

Lib/test/libregrtest/refleak.py:232–273  ·  view source on GitHub ↗
(fs, ps, pic, zdc, abcs, linecache_data)

Source from the content-addressed store, hash-verified

230
231
232def dash_R_cleanup(fs, ps, pic, zdc, abcs, linecache_data):
233 import copyreg
234 import collections.abc
235
236 # Restore some original values.
237 warnings.filters[:] = fs
238 copyreg.dispatch_table.clear()
239 copyreg.dispatch_table.update(ps)
240 sys.path_importer_cache.clear()
241 sys.path_importer_cache.update(pic)
242 lcache, linteractive = linecache_data
243 linecache._interactive_cache.clear()
244 linecache._interactive_cache.update(linteractive)
245 linecache.cache.clear()
246 linecache.cache.update(lcache)
247 try:
248 import zipimport
249 except ImportError:
250 pass # Run unmodified on platforms without zipimport support
251 else:
252 zipimport._zip_directory_cache.clear()
253 zipimport._zip_directory_cache.update(zdc)
254
255 # Clear ABC registries, restoring previously saved ABC registries.
256 abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
257 abs_classes = filter(isabstract, abs_classes)
258 for abc in abs_classes:
259 for obj in abc.__subclasses__() + [abc]:
260 refs = abcs.get(obj, None)
261 if refs is not None:
262 obj._abc_registry_clear()
263 for ref in refs:
264 subclass = ref()
265 if subclass is not None:
266 obj.register(subclass)
267 obj._abc_caches_clear()
268
269 # Clear caches
270 clear_caches()
271
272 # Clear other caches last (previous function calls can re-populate them):
273 sys._clear_internal_caches()
274
275
276def warm_caches() -> None:

Callers 1

runtest_refleakFunction · 0.85

Calls 10

getattrFunction · 0.85
filterFunction · 0.85
clear_cachesFunction · 0.85
__subclasses__Method · 0.80
clearMethod · 0.45
updateMethod · 0.45
getMethod · 0.45
_abc_registry_clearMethod · 0.45
registerMethod · 0.45
_abc_caches_clearMethod · 0.45

Tested by

no test coverage detected