Skip to content

Commit 217c789

Browse files
committed
bpo-44852: Support filtering over warnings without a set message
Additional improvements: - messages which were compiled regular expressions aren't unpacked back into strings for unmatched warnings; - removed unnecessary "if tokens:" check (there's one before the for loop).
1 parent 783e66c commit 217c789

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Lib/test/support/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,10 +3260,11 @@ def clear_ignored_deprecations(*tokens: object) -> None:
32603260
for action, message, category, module, lineno in warnings.filters:
32613261
if action == "ignore" and category is DeprecationWarning:
32623262
if isinstance(message, re.Pattern):
3263-
message = message.pattern
3264-
if tokens:
3265-
endswith = tuple(rf"(?#support{id(token)})" for token in tokens)
3266-
if message.endswith(endswith):
3263+
msg = message.pattern
3264+
else:
3265+
msg = message or ""
3266+
endswith = tuple(rf"(?#support{id(token)})" for token in tokens)
3267+
if msg.endswith(endswith):
32673268
continue
32683269
new_filters.append((action, message, category, module, lineno))
32693270
if warnings.filters != new_filters:

0 commit comments

Comments
 (0)