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

Skip to content

Commit b11bd03

Browse files
committed
Fix bugs with integer-valued variables when parsing Makefiles. Values
for done[n] can be integers as well as strings, but the code concatenates them with strings (fixed by adding a str()) and calls string.strip() on them (fixed by rearranging the logic) (Presumably this wasn't noticed previously because parse_makefile() was only called on Modules/Makefile, which contains no integer-valued variables.)
1 parent 9710297 commit b11bd03

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/distutils/sysconfig.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,15 @@ def parse_makefile(fn, g=None):
204204
n = m.group(1)
205205
if done.has_key(n):
206206
after = value[m.end():]
207-
value = value[:m.start()] + done[n] + after
207+
value = value[:m.start()] + str(done[n]) + after
208208
if "$" in after:
209209
notdone[name] = value
210210
else:
211211
try: value = string.atoi(value)
212-
except ValueError: pass
213-
done[name] = string.strip(value)
212+
except ValueError:
213+
done[name] = string.strip(value)
214+
else:
215+
done[name] = value
214216
del notdone[name]
215217
elif notdone.has_key(n):
216218
# get it on a subsequent round
@@ -223,8 +225,10 @@ def parse_makefile(fn, g=None):
223225
notdone[name] = value
224226
else:
225227
try: value = string.atoi(value)
226-
except ValueError: pass
227-
done[name] = string.strip(value)
228+
except ValueError:
229+
done[name] = string.strip(value)
230+
else:
231+
done[name] = value
228232
del notdone[name]
229233
else:
230234
# bogus variable reference; just drop it since we can't deal

0 commit comments

Comments
 (0)