Skip to content

Commit e2c0326

Browse files
committed
Catch warnings in stdlib
1 parent 5172fda commit e2c0326

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Lib/site.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import _sitebuiltins
7676
import io
7777
import stat
78+
import warnings
7879

7980
# Prefixes for site-packages; add additional prefixes like /usr/local here
8081
PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -318,7 +319,10 @@ def joinuser(*args):
318319
# Same to sysconfig.get_path('purelib', os.name+'_user')
319320
def _get_path(userbase):
320321
version = sys.version_info
321-
if hasattr(sys, 'abiflags') and 't' in sys.abiflags:
322+
with warnings.catch_warnings():
323+
warnings.simplefilter('ignore', DeprecationWarning)
324+
abiflags = getattr(sys, 'abiflags', '')
325+
if 't' in abiflags:
322326
abi_thread = 't'
323327
else:
324328
abi_thread = ''
@@ -400,7 +404,10 @@ def getsitepackages(prefixes=None):
400404

401405
implementation = _get_implementation().lower()
402406
ver = sys.version_info
403-
if hasattr(sys, 'abiflags') and 't' in sys.abiflags:
407+
with warnings.catch_warnings():
408+
warnings.simplefilter('ignore', DeprecationWarning)
409+
abiflags = getattr(sys, 'abiflags', '')
410+
if 't' in abiflags:
404411
abi_thread = 't'
405412
else:
406413
abi_thread = ''

Lib/sysconfig/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ def get_path(name, scheme=get_default_scheme(), vars=None, expand=True):
496496

497497

498498
def _init_config_vars():
499+
import warnings
500+
499501
global _CONFIG_VARS
500502
_CONFIG_VARS = {}
501503

@@ -505,7 +507,9 @@ def _init_config_vars():
505507
base_exec_prefix = _BASE_EXEC_PREFIX
506508

507509
try:
508-
abiflags = sys.abiflags
510+
with warnings.catch_warnings():
511+
warnings.simplefilter('ignore', DeprecationWarning)
512+
abiflags = sys.abiflags
509513
except AttributeError:
510514
abiflags = ''
511515

0 commit comments

Comments
 (0)