8000 gh-128978: Fix a `NameError` in `sysconfig.expand_makefile_vars` by picnixz · Pull Request #128979 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128978: Fix a NameError in sysconfig.expand_makefile_vars #128979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix a NameError in sysconfig.expand_makefile_vars.
  • Loading branch information
picnixz committed Jan 18, 2025
commit e604f5d0709a3fda991d7619b6efc634b1442344
5 changes: 4 additions & 1 deletion Lib/sysconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,14 +718,17 @@ def expand_makefile_vars(s, vars):
"""
import re

find_var1_re = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)")
find_var2_re = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")

# This algorithm does multiple expansion, so if vars['foo'] contains
# "${bar}", it will expand ${foo} to ${bar}, and then expand
# ${bar}... and so forth. This is fine as long as 'vars' comes from
# 'parse_makefile()', which takes care of such expansions eagerly,
# according to make's variable expansion semantics.

while True:
m = re.search(_findvar1_rx, s) or re.search(_findvar2_rx, s)
m = find_var1_re.search(s) or find_var2_re.search(s)
if m:
(beg, end) = m.span()
s = s[0:beg] + vars.get(m.group(1)) + s[end:]
Expand Down
0