mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
git-hyper-blame: Fix unicode handling.
git hyper_blame might use a subprocess' stdin for its stdout, which is opened to accept byte input. The text must be encoded before printing to stdout to avoid unicode errors. Bug: 1028709 Change-Id: If2a270a7f3f69a818d367616f6732245de364db9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1937500 Reviewed-by: Andy Perelson <ajp@chromium.org> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
@@ -95,7 +95,7 @@ def parse_blame(blameoutput):
|
||||
yield BlameLine(commit, context, lineno_then, lineno_now, False)
|
||||
|
||||
|
||||
def print_table(table, colsep=' ', rowsep='\n', align=None, out=sys.stdout):
|
||||
def print_table(table, align=None, out=sys.stdout):
|
||||
"""Print a 2D rectangular array, aligning columns with spaces.
|
||||
|
||||
Args:
|
||||
@@ -124,9 +124,10 @@ def print_table(table, colsep=' ', rowsep='\n', align=None, out=sys.stdout):
|
||||
elif i < len(row) - 1:
|
||||
# Do not pad the final column if left-aligned.
|
||||
cell += padding
|
||||
cell = cell.encode('utf-8', 'replace')
|
||||
cells.append(cell)
|
||||
try:
|
||||
print(*cells, sep=colsep, end=rowsep, file=out)
|
||||
out.write(b' '.join(cells) + b'\n')
|
||||
except IOError: # pragma: no cover
|
||||
# Can happen on Windows if the pipe is closed early.
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user