diff options
-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 c89901e..a86bfca 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2070,13 +2070,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: |