Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e2d076

Browse files
committed
In subst_vars(), change the name of the argument from str to s to
prevent binding for str from masking use of builtin str in nested function. (This is the only case I found in the standard library where a local shadows a global or builtin. There may be others, but the regression test doesn't catch them.)
1 parent a39414b commit 5e2d076

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/distutils/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def check_environ ():
142142
_environ_checked = 1
143143

144144

145-
def subst_vars (str, local_vars):
145+
def subst_vars (s, local_vars):
146146
"""Perform shell/Perl-style variable substitution on 'string'. Every
147147
occurrence of '$' followed by a name is considered a variable, and
148148
variable is substituted by the value found in the 'local_vars'
@@ -160,7 +160,7 @@ def _subst (match, local_vars=local_vars):
160160
return os.environ[var_name]
161161

162162
try:
163-
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, str)
163+
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
164164
except KeyError, var:
165165
raise ValueError, "invalid variable '$%s'" % var
166166

0 commit comments

Comments
 (0)