(fs, ps, pic, zdc, abcs, linecache_data)
| 230 | |
| 231 | |
| 232 | def 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 | |
| 276 | def warm_caches() -> None: |
no test coverage detected