Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1369)

Unified Diff: presubmit_support.py

Issue 4108011: Fix decoding to work more often with various encodings found on platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index f6216432f76c282e90234426eb32aa2da32dfd97..8ab01daae39dcd2ebc21fa522c3d798b79df5d35 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -114,8 +114,15 @@ class OutputApi(object):
if len(self._items) > 0:
output_stream.write(' ' + ' \\\n '.join(map(str, self._items)) + '\n')
if self._long_text:
+ # Sometimes self._long_text is a ascii string, a codepage string
+ # (on windows), or a unicode object.
+ try:
+ long_text = self._long_text.decode()
+ except UnicodeDecodeError:
+ long_text = self._long_text.decode('ascii', 'replace')
+
output_stream.write('\n***************\n%s\n***************\n' %
- self._long_text.encode('ascii', 'replace'))
+ long_text)
if self.ShouldPrompt() and may_prompt:
if not PromptYesNo(input_stream, output_stream,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698