Commit f946b22f authored by maruel@chromium.org's avatar maruel@chromium.org

Revert r79006: "Add code to 'fix' python encoding and it's unit test."

It is causing exception for some users on ubuntu 10.4 with:
"category LC_ALL is not supported"

TBR=dpranke

Review URL: http://codereview.chromium.org/6717025

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79012 0039d316-1c4b-4281-b951-d872f2087c98
parent 8e741d3b
...@@ -9,7 +9,6 @@ details on the presubmit API built into gcl. ...@@ -9,7 +9,6 @@ details on the presubmit API built into gcl.
""" """
UNIT_TESTS = [ UNIT_TESTS = [
'tests.fix_encoding_test',
'tests.gcl_unittest', 'tests.gcl_unittest',
'tests.gclient_scm_test', 'tests.gclient_scm_test',
'tests.gclient_smoketest', 'tests.gclient_smoketest',
......
This diff is collapsed.
...@@ -40,7 +40,6 @@ import breakpad # pylint: disable=W0611 ...@@ -40,7 +40,6 @@ import breakpad # pylint: disable=W0611
# gcl now depends on gclient. # gcl now depends on gclient.
from scm import SVN from scm import SVN
import fix_encoding
import gclient_utils import gclient_utils
import owners import owners
import presubmit_support import presubmit_support
...@@ -1474,5 +1473,4 @@ def main(argv): ...@@ -1474,5 +1473,4 @@ def main(argv):
if __name__ == "__main__": if __name__ == "__main__":
fix_encoding.fix_encoding()
sys.exit(main(sys.argv[1:])) sys.exit(main(sys.argv[1:]))
...@@ -64,7 +64,6 @@ import urllib ...@@ -64,7 +64,6 @@ import urllib
import breakpad # pylint: disable=W0611 import breakpad # pylint: disable=W0611
import fix_encoding
import gclient_scm import gclient_scm
import gclient_utils import gclient_utils
from third_party.repo.progress import Progress from third_party.repo.progress import Progress
...@@ -1267,7 +1266,6 @@ def Main(argv): ...@@ -1267,7 +1266,6 @@ def Main(argv):
if '__main__' == __name__: if '__main__' == __name__:
fix_encoding.fix_encoding()
sys.exit(Main(sys.argv[1:])) sys.exit(Main(sys.argv[1:]))
# vim: ts=2:sw=2:tw=80:et: # vim: ts=2:sw=2:tw=80:et:
...@@ -50,7 +50,6 @@ except ImportError: ...@@ -50,7 +50,6 @@ except ImportError:
import simplejson as json # pylint: disable=F0401 import simplejson as json # pylint: disable=F0401
# Local imports. # Local imports.
import fix_encoding
import gclient_utils import gclient_utils
import owners import owners
import presubmit_canned_checks import presubmit_canned_checks
...@@ -143,18 +142,18 @@ class OutputApi(object): ...@@ -143,18 +142,18 @@ class OutputApi(object):
def handle(self, output): def handle(self, output):
output.write(self._message) output.write(self._message)
output.write('\n') output.write('\n')
for index, item in enumerate(self._items): if len(self._items) > 0:
output.write(' ') output.write(' ' + ' \\\n '.join(map(str, self._items)) + '\n')
# Write separately in case it's unicode.
output.write(item)
if index < len(self._items) - 1:
output.write(' \\')
output.write('\n')
if self._long_text: if self._long_text:
output.write('\n***************\n') # Sometimes self._long_text is a ascii string, a codepage string
# Write separately in case it's unicode. # (on windows), or a unicode object.
output.write(self._long_text) try:
output.write('\n***************\n') long_text = self._long_text.decode()
except UnicodeDecodeError:
long_text = self._long_text.decode('ascii', 'replace')
output.write('\n***************\n%s\n***************\n' %
long_text)
if self.fatal: if self.fatal:
output.fail() output.fail()
...@@ -1193,5 +1192,4 @@ def Main(argv): ...@@ -1193,5 +1192,4 @@ def Main(argv):
if __name__ == '__main__': if __name__ == '__main__':
fix_encoding.fix_encoding()
sys.exit(Main(None)) sys.exit(Main(None))
#!/usr/bin/python
# coding=utf8
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for fix_encoding.py."""
import os
import sys
import unittest
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, ROOT_DIR)
import fix_encoding
class FixEncodingTest(unittest.TestCase):
# Nice mix of latin, hebrew, arabic and chinese. Doesn't mean anything.
text = u'Héllô 偉大 سيد'
def test_code_page(self):
# Make sure printing garbage won't throw.
print self.text.encode() + '\xff'
print >> sys.stderr, self.text.encode() + '\xff'
def test_utf8(self):
# Make sure printing utf-8 works.
print self.text.encode('utf-8')
print >> sys.stderr, self.text.encode('utf-8')
def test_unicode(self):
# Make sure printing unicode works.
print self.text
print >> sys.stderr, self.text
def test_default_encoding(self):
self.assertEquals('utf-8', sys.getdefaultencoding())
def test_win_console(self):
if sys.platform != 'win32':
return
# This should fail if redirected. Can be checked with:
# python fix_encoding_test.py > a
self.assertEquals(
sys.stdout.__class__, fix_encoding.WinUnicodeConsoleOutput)
self.assertEquals(
sys.stderr.__class__, fix_encoding.WinUnicodeConsoleOutput)
self.assertEquals(sys.stdout.encoding, sys.getdefaultencoding())
self.assertEquals(sys.stderr.encoding, sys.getdefaultencoding())
def test_multiple_calls(self):
# Shouldn't do anything.
self.assertEquals(False, fix_encoding.fix_encoding())
if __name__ == '__main__':
assert fix_encoding.fix_encoding()
unittest.main()
...@@ -90,8 +90,7 @@ class GclUnittest(GclTestsBase): ...@@ -90,8 +90,7 @@ class GclUnittest(GclTestsBase):
'OptionallyDoPresubmitChecks', 'REPOSITORY_ROOT', 'REVIEWERS_REGEX', 'OptionallyDoPresubmitChecks', 'REPOSITORY_ROOT', 'REVIEWERS_REGEX',
'RunShell', 'RunShellWithReturnCode', 'SVN', 'RunShell', 'RunShellWithReturnCode', 'SVN',
'TryChange', 'UnknownFiles', 'Warn', 'TryChange', 'UnknownFiles', 'Warn',
'attrs', 'breakpad', 'defer_attributes', 'fix_encoding', 'attrs', 'breakpad', 'defer_attributes', 'gclient_utils', 'getpass',
'gclient_utils', 'getpass',
'json', 'main', 'need_change', 'need_change_and_args', 'no_args', 'json', 'main', 'need_change', 'need_change_and_args', 'no_args',
'optparse', 'os', 'owners', 'presubmit_support', 'random', 're', 'optparse', 'os', 'owners', 'presubmit_support', 'random', 're',
'string', 'subprocess', 'suggest_reviewers', 'sys', 'tempfile', 'string', 'subprocess', 'suggest_reviewers', 'sys', 'tempfile',
......
...@@ -141,8 +141,7 @@ class PresubmitUnittest(PresubmitTestsBase): ...@@ -141,8 +141,7 @@ class PresubmitUnittest(PresubmitTestsBase):
'NotImplementedException', 'OutputApi', 'ParseFiles', 'NotImplementedException', 'OutputApi', 'ParseFiles',
'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs', 'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs',
'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO', 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO',
'exceptions', 'fix_encoding', 'fnmatch', 'gclient_utils', 'glob', 'json', 'exceptions', 'fnmatch', 'gclient_utils', 'glob', 'json', 'load_files',
'load_files',
'logging', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle', 'logging', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle',
'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess', 'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess',
'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2', 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2',
......
...@@ -45,8 +45,7 @@ class TryChangeUnittest(TryChangeTestsBase): ...@@ -45,8 +45,7 @@ class TryChangeUnittest(TryChangeTestsBase):
'EPILOG', 'Escape', 'GIT', 'GuessVCS', 'GetMungedDiff', 'HELP_STRING', 'EPILOG', 'Escape', 'GIT', 'GuessVCS', 'GetMungedDiff', 'HELP_STRING',
'InvalidScript', 'NoTryServerAccess', 'PrintSuccess', 'SCM', 'SVN', 'InvalidScript', 'NoTryServerAccess', 'PrintSuccess', 'SCM', 'SVN',
'TryChange', 'USAGE', 'TryChange', 'USAGE',
'breakpad', 'datetime', 'errno', 'fix_encoding', 'gcl', 'gclient_utils', 'breakpad', 'datetime', 'errno', 'gcl', 'gclient_utils', 'getpass',
'getpass',
'json', 'logging', 'optparse', 'os', 'posixpath', 're', 'scm', 'shutil', 'json', 'logging', 'optparse', 'os', 'posixpath', 're', 'scm', 'shutil',
'sys', 'tempfile', 'urllib', 'sys', 'tempfile', 'urllib',
] ]
......
...@@ -39,7 +39,6 @@ try: ...@@ -39,7 +39,6 @@ try:
except ImportError: except ImportError:
gcl = None gcl = None
import fix_encoding
import gclient_utils import gclient_utils
import scm import scm
...@@ -770,5 +769,4 @@ def TryChange(argv, ...@@ -770,5 +769,4 @@ def TryChange(argv,
if __name__ == "__main__": if __name__ == "__main__":
fix_encoding.fix_encoding()
sys.exit(TryChange(None, [], False)) sys.exit(TryChange(None, [], False))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment