Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26673 closed Bug (fixed)

i18n tests: Unicode in enviroment vars isn't accepted on Python2+Windows

Reported by: Ramiro Morales Owned by: Ramiro Morales
Component: Internationalization Version: dev
Severity: Normal Keywords: windows i18n
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Starting with 5005b527 and eda306f1 we are adding uLANG=C to the enviroment on which a test case (i18n.test_compilation.CompilationErrorHandling.test_msgfmt_error_including_non_ascii) is run.

On Windows + Python 2.7 this is causing the following error:

======================================================================                                                     
ERROR: test_msgfmt_error_including_non_ascii (i18n.test_compilation.CompilationErrorHandling)                              
----------------------------------------------------------------------                                                     
Traceback (most recent call last):
  File "C:\django\upstream\tests\i18n\test_compilation.py", line 179, in test_msgfmt_error_including_non_ascii
    call_command('compilemessages', locale=['ko'], verbosity=0)
  File "C:\django\upstream\django\core\management\__init__.py", line 130, in call_command
    return command.execute(*args, **defaults)
  File "C:\django\upstream\django\core\management\base.py", line 356, in execute
    output = self.handle(*args, **options)
  File "C:\django\upstream\django\core\management\commands\compilemessages.py", line 103, in handle
    self.compile_messages(locations)
  File "C:\django\upstream\django\core\management\commands\compilemessages.py", line 128, in compile_messages 
    output, errors, status = popen_wrapper(args)
  File "C:\django\upstream\django\core\management\utils.py", line 21, in popen_wrapper
    p = Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt')
  File "C:\django\upstream\tests\i18n\test_compilation.py", line 175, in <lambda>
    with mock.patch('django.core.management.utils.Popen', lambda *args, **kwargs: Popen(*args, env=env, **kwargs)):
  File "C:\py27-64\Lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\py27-64\Lib\subprocess.py", line 958, in execute_child
    startupinfo)
TypeError: environment can only contain strings                                                

This is caused by the fact that this Python version+OS combination needs bytestrings as env var value and name (at least Python 2.7 on Linux doesn't seem to be as picky).

This is related to our usage of from __future__ import unicode_literals on that module.

Other projects faced similar problems:

Change History (4)

comment:1 by Ramiro Morales, 9 years ago

Keywords: windows i18n added
Owner: changed from nobody to Ramiro Morales
Status: newassigned

comment:2 by Tim Graham, 9 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:3 by Ramiro Morales <cramm0@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 15a5755:

Fixed #26673 -- Fixed a I18N test case error on Windows+Python 2.7.

subprocess.Popen doesn't accept enviroment vars with Unicode var name
or value.

comment:4 by Tim Graham <timograham@…>, 9 years ago

In e0a4d447:

[1.10.x] Fixed #26673 -- Fixed a I18N test case error on Windows+Python 2.7.

subprocess.Popen doesn't accept enviroment vars with Unicode var name
or value.

Backport of 15a5755e7cca630c2a0dbbcba436621ccc437c21 from master

Note: See TracTickets for help on using tickets.
Back to Top