Skip to content

Commit b0e1f9c

Browse files
authored
gh-99201: fix IndexError when initializing sysconfig config variables
1 parent 858cb79 commit b0e1f9c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/sysconfig.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,12 @@ def _init_non_posix(vars):
544544
vars['LIBDEST'] = get_path('stdlib')
545545
vars['BINLIBDEST'] = get_path('platstdlib')
546546
vars['INCLUDEPY'] = get_path('include')
547-
vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
547+
try:
548+
# GH-99201: _imp.extension_suffixes may be empty when
549+
# HAVE_DYNAMIC_LOADING is not set. In this case, don't set EXT_SUFFIX.
550+
vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
551+
except IndexError:
552+
pass
548553
vars['EXE'] = '.exe'
549554
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
550555
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :exc:`IndexError` when initializing the config variables on Windows if
2+
``HAVE_DYNAMIC_LOADING`` is not set.

0 commit comments

Comments
 (0)