[Python-checkins] gh-99201: fix IndexError when initializing sysconfig config variables
FFY00
webhook-mailer at python.org
Sat Nov 19 15:47:15 EST 2022
https://github.com/python/cpython/commit/b0e1f9c241cd8f8c864d51059217f997d3b792bf
commit: b0e1f9c241cd8f8c864d51059217f997d3b792bf
branch: main
author: Filipe Laíns <lains at riseup.net>
committer: FFY00 <filipe.lains at gmail.com>
date: 2022年11月19日T20:47:09Z
summary:
gh-99201: fix IndexError when initializing sysconfig config variables
files:
A Misc/NEWS.d/next/Library/2022-11-09-03-34-29.gh-issue-99201.lDJ7xI.rst
M Lib/sysconfig.py
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 73c25684db20..c61100a6da85 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -544,7 +544,12 @@ def _init_non_posix(vars):
vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include')
- vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
+ try:
+ # GH-99201: _imp.extension_suffixes may be empty when
+ # HAVE_DYNAMIC_LOADING is not set. In this case, don't set EXT_SUFFIX.
+ vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
+ except IndexError:
+ pass
vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
diff --git a/Misc/NEWS.d/next/Library/2022-11-09-03-34-29.gh-issue-99201.lDJ7xI.rst b/Misc/NEWS.d/next/Library/2022-11-09-03-34-29.gh-issue-99201.lDJ7xI.rst
new file mode 100644
index 000000000000..6d03574fdaf5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-11-09-03-34-29.gh-issue-99201.lDJ7xI.rst
@@ -0,0 +1,2 @@
+Fix :exc:`IndexError` when initializing the config variables on Windows if
+``HAVE_DYNAMIC_LOADING`` is not set.
More information about the Python-checkins
mailing list