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 amaury.forgeotdarc
Recipients Drekin, amaury.forgeotdarc, ezio.melotti
Date 2013-04-02.20:27:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The issue is actually with compile():
  compile('x=1', '\', 'exec')
fails on my Western Windows machine (mbcs = cp1252).
This conversion should not be necessary, since the filename is only used for error messages (and decoded again!)

But unfortunately the various API functions used by compile() are documented to take a filename encoded with the filesystem encoding:
This API is unfortunate; on Windows Python should never have to convert filenames unless bytes strings are explicitly used.

I can see two ways to fix the issue:
- build another set of APIs which take unicode strings for the filename, or at least encoded to UTF-8.
- use some trick for unencodable filenames; filename.encode('mbcs', 'backslashreplace') works, but does not round-trip (and cannot fetch source code in tracebacks). I don't know if there is some variant of surrogateescape that we could use.
Date User Action Args
2013-04-02 20:27:32amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, ezio.melotti, Drekin
2013-04-02 20:27:32amaury.forgeotdarcsetmessageid: <>
2013-04-02 20:27:32amaury.forgeotdarclinkissue17588 messages
2013-04-02 20:27:31amaury.forgeotdarccreate