Skip to content

Commit a5739ba

Browse files
committed
Simplify sys.abiflags in sysconfig and site
1 parent 7884a62 commit a5739ba

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Lib/sysconfig/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,6 @@ def _init_config_vars():
506506
base_prefix = _BASE_PREFIX
507507
base_exec_prefix = _BASE_EXEC_PREFIX
508508

509-
with warnings.catch_warnings():
510-
# ignore DeprecationWarning on sys.abiflags change on Windows
511-
warnings.simplefilter('ignore', DeprecationWarning)
512-
abiflags = getattr(sys, 'abiflags', '')
513-
514509
if os.name == 'posix':
515510
_init_posix(_CONFIG_VARS)
516511
# If we are cross-compiling, load the prefixes from the Makefile instead.
@@ -520,6 +515,10 @@ def _init_config_vars():
520515
base_prefix = _CONFIG_VARS['host_prefix']
521516
base_exec_prefix = _CONFIG_VARS['host_exec_prefix']
522517
abiflags = _CONFIG_VARS['ABIFLAGS']
518+
else:
519+
abiflags = sys.abiflags
520+
else:
521+
abiflags = '' # sys.abiflags is absent on Windows
523522

524523
# Normalized versions of prefix and exec_prefix are handy to have;
525524
# in fact, these are the standard versions used most places in the

Lib/test/test_sys.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ def test_attributes(self):
719719
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
720720
if not sys.platform.startswith('win'):
721721
self.assertIsInstance(sys.abiflags, str)
722+
723+
# test hasattr(sys, 'abiflags') == (os.name != 'nt)
724+
self.assertEqual(os.name, 'posix')
722725
else:
723726
absent = object()
724727
with self.assertWarnsRegex(
@@ -743,6 +746,9 @@ def test_attributes(self):
743746
):
744747
_ = sys.abiflags
745748

749+
# test hasattr(sys, 'abiflags') == (os.name != 'nt)
750+
self.assertEqual(os.name, 'nt')
751+
746752
def test_thread_info(self):
747753
info = sys.thread_info
748754
self.assertEqual(len(info), 3)

0 commit comments

Comments
 (0)