Skip to content

Commit 42f90a2

Browse files
committedJan 12, 2022
[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
1 parent 6c654b5 commit 42f90a2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎llvm/utils/extract_symbols.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def dumpbin_is_32bit_windows(lib):
111111
def objdump_is_32bit_windows(lib):
112112
output = subprocess.check_output(['objdump','-f',lib],
113113
universal_newlines=True)
114-
for line in output:
114+
for line in output.splitlines():
115115
match = re.match('.+file format (\S+)', line)
116116
if match:
117117
return (match.group(1) == 'pe-i386')
@@ -120,7 +120,7 @@ def objdump_is_32bit_windows(lib):
120120
def readobj_is_32bit_windows(lib):
121121
output = subprocess.check_output(['llvm-readobj','--file-header',lib],
122122
universal_newlines=True)
123-
for line in output:
123+
for line in output.splitlines():
124124
match = re.match('Format: (\S+)', line)
125125
if match:
126126
return (match.group(1) == 'COFF-i386')

0 commit comments

Comments
 (0)
Please sign in to comment.