STINNER Victor added the comment:

Ok, I now understood the issue: the distutils._msvccompiler._get_vc_env() 
functions runs the "C:\Program Files (x86)\Microsoft visual studio 
14.0\VC\vcvarsall.bat" program in a shell and then run the "set" command in the 
same shell to retrieve environment variables set by the batch script.

Problem: The "set" program encodes Unicode environment variables to bytes to 
write them into stdout, but at least one environment variable is not encodable. 
(It's unclear to me which encoding is used: ANSI code page? OEM code page? It 
doesn't matter much.)

Windows provides a nice Unicode API to retrieve environment varaibles. Using 
the "set" program is the wrong approach to retrieve environment varaibles.

I suggest to replace the "set" program with a script Python script which dumps 
all environment variables as UTF-8. The script would use os.environ which uses 
the Windows Unicode API to retrieve environment variables directly as Unicode.

--

Using an error handler is the wrong option here. The root problem is that the 
"set" program replaces unencodable characters with junk. Trying to replace or 
ignore junk doesn't solve the problem. The Visual Studio environment variables 
can contains unencodable characters, we should be able to retrieve them as 
Unicode without using a very limited encoding like cp1252 codepage or any OEM 
code page.

--

Another option is to still use the set program, but completly skip variables 
which contain undecodable bytes. I dislike this option :-/

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27048>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to