Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a :exc:`NameError` in :func:`!sysconfig.expand_makefile_vars`. Patch by
Bénédikt Tran.
Loading