]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99201: fix IndexError when initializing sysconfig config variables
authorFilipe Laíns <lains@riseup.net>
Sat, 19 Nov 2022 20:47:09 +0000 (20:47 +0000)
committerGitHub <noreply@github.com>
Sat, 19 Nov 2022 20:47:09 +0000 (20:47 +0000)
Lib/sysconfig.py
Misc/NEWS.d/next/Library/2022-11-09-03-34-29.gh-issue-99201.lDJ7xI.rst [new file with mode: 0644]

index 73c25684db20c9819bb361d478f31bfdd9f6ce17..c61100a6da8503310dd09866bfc9a6c8d508f538 100644 (file)
@@ -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 (file)
index 0000000..6d03574
--- /dev/null
@@ -0,0 +1,2 @@
+Fix :exc:`IndexError` when initializing the config variables on Windows if
+``HAVE_DYNAMIC_LOADING`` is not set.