| 2384 | self._forwarding_rule = forwarding_rule |
| 2385 | |
| 2386 | def _clear_registries(self): |
| 2387 | if hasattr(warnings, "_filters_mutated"): |
| 2388 | # clearing the registry should not be necessary on new pythons, |
| 2389 | # instead the filters should be mutated. |
| 2390 | warnings._filters_mutated() |
| 2391 | return |
| 2392 | # Simply clear the registry, this should normally be harmless, |
| 2393 | # note that on new pythons it would be invalidated anyway. |
| 2394 | for module in self._tmp_modules: |
| 2395 | if hasattr(module, "__warningregistry__"): |
| 2396 | module.__warningregistry__.clear() |
| 2397 | |
| 2398 | def _filter(self, category=Warning, message="", module=None, record=False): |
| 2399 | if record: |