Page MenuHomePhabricator

Python 2.6.5 script test fails with unicode values in env on Windows (Python issue 6906)
Closed, ResolvedPublic

Description

When running script tests on Python 2.6.5 using Appveyor Windows builds, every test fails with

TypeError: os.environ must contain only str: [('TK_LIBRARY', u'C:\\Python265-x64\\tcl\\tk8.5'), ('TCL_LIBRARY', u'C:\\Python265-x64\\tcl\\tcl8.5'), ('TIX_LIBRARY', u'C:\\Python265-x64\\tcl\\tix8.4.3')]

This exception message is provided by: https://github.com/wikimedia/pywikibot-core/blob/master/tests/utils.py#L561

The original exception message is "TypeError: environment can only contain strings", which comes from the Win32-specific PC/_subprocess.c

https://hg.python.org/cpython/file/99af4b44e7e4/PC/_subprocess.c#l306

That code appears to be identical between Python 2.6.5 and 2.6.6, so my guess is that Python 2.6.6 changed something else.

Ah, these environment variables are set within Python, and were set as a unicode, and this was solved in Python 2.6.6. http://bugs.python.org/issue6906