https://github.com/python/cpython/commit/249a513c38e9e06ce8d38d575a093d2e1ef5cb48
commit: 249a513c38e9e06ce8d38d575a093d2e1ef5cb48
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2026-07-27T18:00:20+02:00
summary:

[3.15] gh-150208: Avoid double-quoting string values in sysconfigdata 
(GH-150209) (GH-154773)

String values from ``pyconfig.h`` were rendered into ``sysconfigdata``
variables, retaining the quotes.
(cherry picked from commit 07ae6f133ad7a4e7ed506f6a511809b1fc3d1465)

Co-authored-by: Stefano Rivera <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst
M Lib/sysconfig/__init__.py
M Lib/test/test_sysconfig.py

diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py
index 47415adce04c2c8..4f8ebf15d367d23 100644
--- a/Lib/sysconfig/__init__.py
+++ b/Lib/sysconfig/__init__.py
@@ -437,6 +437,7 @@ def parse_config_h(fp, vars=None):
     import re
     define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
     undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
+    quoted_re = re.compile('^"(.*)"$')
 
     while True:
         line = fp.readline()
@@ -445,6 +446,8 @@ def parse_config_h(fp, vars=None):
         m = define_rx.match(line)
         if m:
             n, v = m.group(1, 2)
+            if mq := quoted_re.match(v):
+                v = mq.group(1)
             try:
                 if n in _ALWAYS_STR:
                     raise ValueError
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index e6433f76a977b3b..e6f99581f0b7a66 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -576,6 +576,12 @@ def test_linux_ext_suffix(self):
                 expected_suffixes = 'x86_64-linux-gnu.so', 
'x86_64-linux-musl.so'
             self.assertEndsWith(suffix, expected_suffixes)
 
+    @unittest.skipIf(sysconfig.get_config_var('PY_BUILTIN_HASHLIB_HASHES') is 
None,
+                     'PY_BUILTIN_HASHLIB_HASHES required for this test')
+    def test_PY_BUILTIN_HASHLIB_HASHES_in_vars(self):
+        vars = sysconfig.get_config_vars()
+        self.assertFalse(vars['PY_BUILTIN_HASHLIB_HASHES'].startswith('"'))
+
     @unittest.skipUnless(sys.platform == 'android', 'Android-specific test')
     def test_android_ext_suffix(self):
         machine = platform.machine()
diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst
new file mode 100644
index 000000000000000..e9bc1d9e976523b
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst
@@ -0,0 +1,2 @@
+Avoid double-quoting string values from ``pyconfig.h`` in ``sysconfigdata``
+variables.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to