| 2086 | self._forwarding_rule = forwarding_rule |
| 2087 | |
| 2088 | def _clear_registries(self): |
| 2089 | if hasattr(warnings, "_filters_mutated"): |
| 2090 | # clearing the registry should not be necessary on new pythons, |
| 2091 | # instead the filters should be mutated. |
| 2092 | warnings._filters_mutated() |
| 2093 | return |
| 2094 | # Simply clear the registry, this should normally be harmless, |
| 2095 | # note that on new pythons it would be invalidated anyway. |
| 2096 | for module in self._tmp_modules: |
| 2097 | if hasattr(module, "__warningregistry__"): |
| 2098 | module.__warningregistry__.clear() |
| 2099 | |
| 2100 | def _filter(self, category=Warning, message="", module=None, record=False): |
| 2101 | if record: |