id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 19357 Unicode errors when Django is installed under a non-ASCII path kujiu Aymeric Augustin "With Python 2.7, when using the unicode_literals import, all strings in the current files are interpreted as unicode. But, all strings coming from an other file that doesn't contain this import are str. An UnicodeDecodeError occurs when concatenating directly strings from a file with unicode_literals and an other without. But all works fine with Python 3.x. If we start django with django installed on a path containing unicode character (like asian character), a UnicodeDecodeError occurs on file django/utils/translation/trans_real.py (line 112). If an app have a path with unicode character, the error occurs on the same file at line 155. Each time, the traceback stops in posixpath.py (in python lib), with the command ""path += '/' + b"". Django doesn't start, tests don't start, shell doesn't start. Some files in tests have the same issue like : * django/contrib/formtools/tests/__init__.py * django/utils/translation/trans_real.py tests/regressiontests/fixtures_regress/tests.py * tests/regressiontests/i18n/contenttypes/tests.py tests/regressiontests/i18n/patterns/tests.py * tests/regressiontests/i18n/tests.py tests/regressiontests/servers/tests.py * tests/regressiontests/staticfiles_tests/tests.py tests/regressiontests/templates/response.py * tests/regressiontests/test_client_regress/tests.py Example of traceback (with ""runtests.py --settings=test_sqlite""): {{{ Traceback (most recent call last): File ""./runtests.py"", line 327, in options.failfast, args) File ""./runtests.py"", line 170, in django_tests failures = test_runner.run_tests(test_labels, extra_tests=extra_tests) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/test/simple.py"", line 366, in run_tests suite = self.build_suite(test_labels, extra_tests) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/test/simple.py"", line 260, in build_suite suite.addTest(build_suite(app)) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/test/simple.py"", line 68, in build_suite test_module = get_tests(app_module) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/test/simple.py"", line 25, in get_tests test_module = import_module('.'.join(prefix + [TEST_MODULE])) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/utils/importlib.py"", line 35, in import_module __import__(name) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/contrib/flatpages/tests/__init__.py"", line 2, in from django.contrib.flatpages.tests.forms import * File ""/home/kujiu/仕事/labs/projects/django-trunk/django/contrib/flatpages/tests/forms.py"", line 4, in from django.contrib.flatpages.forms import FlatpageForm File ""/home/kujiu/仕事/labs/projects/django-trunk/django/contrib/flatpages/forms.py"", line 6, in class FlatpageForm(forms.ModelForm): File ""/home/kujiu/仕事/labs/projects/django-trunk/django/contrib/flatpages/forms.py"", line 10, in FlatpageForm error_message = _(""This value must contain only letters, numbers,"" File ""/home/kujiu/仕事/labs/projects/django-trunk/django/forms/fields.py"", line 441, in __init__ if error_message: File ""/home/kujiu/仕事/labs/projects/django-trunk/django/utils/functional.py"", line 117, in __wrapper__ res = func(*self.__args, **self.__kw) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/utils/translation/__init__.py"", line 71, in ugettext return _trans.ugettext(message) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/utils/translation/trans_real.py"", line 275, in ugett ext return do_translate(message, 'ugettext') File ""/home/kujiu/仕事/labs/projects/django-trunk/django/utils/translation/trans_real.py"", line 257, in do_tr anslate _default = translation(settings.LANGUAGE_CODE) File ""/home/kujiu/仕事/labs/projects/django-trunk/django/utils/translation/trans_real.py"", line 112, in trans lation globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale') File ""/usr/lib/python2.7/posixpath.py"", line 80, in join path += '/' + b UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 12: ordinal not in range(128) }}}" Bug closed Python 2 dev Release blocker fixed ua_django_bugzilla@… Accepted 1 0 0 1 0 0