This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients abarry, dstufft, eric.araujo, ezio.melotti, martin.panter, paul.moore, r.david.murray, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-05-17.23:27:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463527665.57.0.994251478414.issue27048@psf.upfronthosting.co.za>
In-reply-to
Content
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 :-/
History
Date User Action Args
2016-05-17 23:27:45vstinnersetrecipients: + vstinner, paul.moore, tim.golden, ezio.melotti, eric.araujo, r.david.murray, martin.panter, zach.ware, steve.dower, dstufft, abarry
2016-05-17 23:27:45vstinnersetmessageid: <1463527665.57.0.994251478414.issue27048@psf.upfronthosting.co.za>
2016-05-17 23:27:45vstinnerlinkissue27048 messages
2016-05-17 23:27:45vstinnercreate