FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-150208: Avoid double-quoting string values in sysconfigdata by stefanor · Pull Request #150209 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 3 additions & 0 deletions Lib/sysconfig/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_sysconfig.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Avoid double-quoting string values from ``pyconfig.h`` in ``sysconfigdata``
variables.
Loading

Back | FazBrowse Home | New Git URL