Skip to content

Commit 36efb72

Browse files
committed
Add message regex in warning filters
1 parent 2e79345 commit 36efb72

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Lib/sysconfig/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def get_makefile_filename():
338338
# This flag will always be True since Python 3.16
339339
with warnings.catch_warnings():
340340
# ignore DeprecationWarning on sys.abiflags change on Windows
341-
warnings.simplefilter('ignore', DeprecationWarning)
341+
warnings.filterwarnings('ignore', r'sys\.abiflags', category=DeprecationWarning)
342342
has_abiflags = hasattr(sys, 'abiflags')
343343

344344
if has_abiflags:

Lib/test/pythoninfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def copy_attributes(info_add, obj, name_fmt, attributes, *, formatter=None):
5151
# XXX: Remove this special case handling in Python 3.16
5252
with warnings.catch_warnings():
5353
# ignore DeprecationWarning on sys.abiflags change on Windows
54-
warnings.simplefilter("ignore", DeprecationWarning)
54+
warnings.filterwarnings('ignore', r'sys\.abiflags', category=DeprecationWarning)
5555
value = getattr(obj, attr, None)
5656
else:
5757
value = getattr(obj, attr, None)

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ def check_bolt_optimized():
881881
# This flag will always be True since Python 3.16
882882
with warnings.catch_warnings():
883883
# ignore DeprecationWarning on sys.abiflags change on Windows
884-
warnings.simplefilter('ignore', DeprecationWarning)
884+
warnings.filterwarnings('ignore', r'sys\.abiflags', category=DeprecationWarning)
885885
# Equal to `not sys.platform.startswith('win')` prior to 3.16
886886
HAS_SYS_ABIFLAGS = hasattr(sys, 'abiflags')
887887

0 commit comments

Comments
 (0)