[extract_symbols.py] Fix line-splitting of tool output.

Two functions in the `is_32bit_windows` family were retrieving the
output of a tool via `subprocess.check_output`, and then iterating
over it using `for line in output`. But in Python, that gets you the
output one //character// at a time, not a line at a time. So the
regexes that looked for a platform name were never matching.

(This is a mistake that Python makes uniquely easy, because iterating
over a file and over a string have different default behaviour, and
because the element type of a string is still a string so you don't
even get a type mismatch error to warn you about it!)

Reviewed By: michaelplatings

Differential Revision: https://reviews.llvm.org/D117030
This commit is contained in:
Simon Tatham 2022-01-12 09:06:54 +00:00
parent 6c654b5198
commit 42f90a28a3
1 changed files with 2 additions and 2 deletions

View File

@ -111,7 +111,7 @@ def dumpbin_is_32bit_windows(lib):
def objdump_is_32bit_windows(lib):
output = subprocess.check_output(['objdump','-f',lib],
universal_newlines=True)
for line in output:
for line in output.splitlines():
match = re.match('.+file format (\S+)', line)
if match:
return (match.group(1) == 'pe-i386')
@ -120,7 +120,7 @@ def objdump_is_32bit_windows(lib):
def readobj_is_32bit_windows(lib):
output = subprocess.check_output(['llvm-readobj','--file-header',lib],
universal_newlines=True)
for line in output:
for line in output.splitlines():
match = re.match('Format: (\S+)', line)
if match:
return (match.group(1) == 'COFF-i386')