(fs, ps, pic, zdc, abcs, linecache_data)
| 237 | |
| 238 | |
| 239 | def dash_R_cleanup(fs, ps, pic, zdc, abcs, linecache_data): |
| 240 | import copyreg |
| 241 | import collections.abc |
| 242 | |
| 243 | # Restore some original values. |
| 244 | warnings.filters[:] = fs |
| 245 | copyreg.dispatch_table.clear() |
| 246 | copyreg.dispatch_table.update(ps) |
| 247 | sys.path_importer_cache.clear() |
| 248 | sys.path_importer_cache.update(pic) |
| 249 | lcache, linteractive = linecache_data |
| 250 | linecache._interactive_cache.clear() |
| 251 | linecache._interactive_cache.update(linteractive) |
| 252 | linecache.cache.clear() |
| 253 | linecache.cache.update(lcache) |
| 254 | try: |
| 255 | import zipimport |
| 256 | except ImportError: |
| 257 | pass # Run unmodified on platforms without zipimport support |
| 258 | else: |
| 259 | zipimport._zip_directory_cache.clear() |
| 260 | zipimport._zip_directory_cache.update(zdc) |
| 261 | |
| 262 | # Clear ABC registries, restoring previously saved ABC registries. |
| 263 | abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__] |
| 264 | with warnings.catch_warnings(action='ignore', category=DeprecationWarning): |
| 265 | abs_classes.append(collections.abc.ByteString) |
| 266 | abs_classes = filter(isabstract, abs_classes) |
| 267 | for abc in abs_classes: |
| 268 | for obj in abc.__subclasses__() + [abc]: |
| 269 | refs = abcs.get(obj, None) |
| 270 | if refs is not None: |
| 271 | obj._abc_registry_clear() |
| 272 | for ref in refs: |
| 273 | subclass = ref() |
| 274 | if subclass is not None: |
| 275 | obj.register(subclass) |
| 276 | obj._abc_caches_clear() |
| 277 | |
| 278 | # Clear caches |
| 279 | clear_caches() |
| 280 | |
| 281 | # Clear other caches last (previous function calls can re-populate them): |
| 282 | sys._clear_internal_caches() |
| 283 | |
| 284 | |
| 285 | def warm_caches() -> None: |
no test coverage detected
searching dependent graphs…