_dumbwin32proc breaks with unicode environmental variables

[email protected]
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from ivank <[email protected]>:

Windows supports unicode environmental variables. pywin32 supports spawning processes with str or unicode environmental variables, but not a mix of them:

{{{
...
  File "C:\Python26\lib\site-packages\twisted\internet\utils.py", line 25, in _callProtocolWithDeferred
    reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
  File "C:\Python26\lib\site-packages\twisted\internet\posixbase.py", line 234, in spawnProcess
    return Process(self, processProtocol, executable, args, env, path)
  File "C:\Python26\lib\site-packages\twisted\internet\_dumbwin32proc.py", line 176, in __init__
    doCreate()
  File "C:\Python26\lib\site-packages\twisted\internet\_dumbwin32proc.py", line 174, in doCreate
    command, cmdline, None, None, 1, 0, env, path, StartupInfo)
exceptions.TypeError: All dictionary items must be strings, or all must be unicode
}}}

This problem and "solution" is sort of documented here:
https://realityforge.vrsource.org/viewvc/maestro/trunk/maestro/daemon/plugins/services/launch/process.py , near "win32process.CreateProcess requires that all environment keys and"

This bug causes a lot of test failures with twisted.web2 on Windows Vista or Windows 7. The default install of Python 2.6.2 on these operating systems introduces environmental variables with unicode values:

C:\>python -c "import Tkinter, os; exec 'for k, v in os.environ.iteritems():\n\tif isinstance(v, unicode): print k, v'"
TK_LIBRARY C:\Python26\tcl\tk8.5
TIX_LIBRARY C:\Python26\tcl\tix8.4.3
TCL_LIBRARY C:\Python26\tcl\tcl8.5

----------
Type     : defect
Component: core
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/3964
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.