diff options
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r-- | Lib/test/support/__init__.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 39dea88..7e5a29b 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -3257,13 +3257,14 @@ def clear_ignored_deprecations(*tokens: object) -> None: raise ValueError("Provide token or tokens returned by ignore_deprecations_from") new_filters = [] + endswith = tuple(rf"(?#support{id(token)})" for token in tokens) for action, message, category, module, lineno in warnings.filters: if action == "ignore" and category is DeprecationWarning: if isinstance(message, re.Pattern): - message = message.pattern - if tokens: - endswith = tuple(rf"(?#support{id(token)})" for token in tokens) - if message.endswith(endswith): + msg = message.pattern + else: + msg = message or "" + if msg.endswith(endswith): continue new_filters.append((action, message, category, module, lineno)) if warnings.filters != new_filters: |