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, |