[PATCH] D117030: [extract_symbols.py] Fix line-splitting of tool output.
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 11 08:27:52 PST 2022
simon_tatham created this revision.
simon_tatham added reviewers: MaskRay, rnk, john.brawn, lenary.
simon_tatham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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!)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117030
Files:
llvm/utils/extract_symbols.py
Index: llvm/utils/extract_symbols.py
===================================================================
--- llvm/utils/extract_symbols.py
+++ llvm/utils/extract_symbols.py
@@ -111,7 +111,7 @@
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 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')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117030.398963.patch
Type: text/x-patch
Size: 917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220111/7c6561d8/attachment.bin>
More information about the llvm-commits
mailing list