python3: Fix unicode and gettext

In Python 2, ensure that the _() that gets installed into built-ins
always returns unicodes.  This matches the default behavior under Python
3, although that keyword argument is not present in the Python 3 API.

Change-Id: If9e7bb07f389149b3dcf4314f6b2b4faf2b659d0
Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
Chuck Short 2013-07-21 21:12:36 -04:00
parent 3a1224532e
commit 2ec1386120

@ -39,7 +39,13 @@ import pep8
logging.disable('LOG')
# Import tests need to inject _ properly into the builtins
gettext.install('hacking', unicode=1)
kwargs = {}
if sys.version_info[0] < 3:
# In Python2, eusnure that the _() that gets installed into built-ins
# always returns unicodes. This matches the default behavior under Python
# 3, although the keyword arguement is not present in the Python 3 API.
kwargs['unicode'] = True
gettext.install('hacking', **kwargs)
def flake8ext(f):