[issue13758] compile() should not encode 'filename' (at least on Windows)
Drekin added the comment: Since this issue was fixed, shouldn't it be marked fixed here? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
STINNER Victor added the comment: Closed. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
STINNER Victor added the comment: This issue has been fixed in issue #11619 by: New changeset df2fdd42b375 by Victor Stinner in branch 'default': Close #11619: The parser and the import machinery do not encode Unicode http://hg.python.org/cpython/rev/df2fdd42b375 Thanks for the report! (I don't plan to backport the fix to Python 3.3, it's a huge patch for a rare use case.) -- versions: +Python 3.4 -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
Drekin added the comment: Hello. Will this be fixed? It's really annoying that you cannot pass valid unicode filename to compile(). I'm using a workaround: I just pass placeholder and then “update” the resulting code object recursively to set the correct co_filename. Afterwards the code object can be executed and produces correct tracebacks. (I'm using Windows.) Fixing this will probably fix also http://bugs.python.org/issue17588 . It doesn't bother just me. See e.g. http://stackoverflow.com/questions/8798591/unicodeencodeerror-when-using-the-compile-function . Thank you. Drekin -- nosy: +Drekin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
Terry J. Reedy added the comment: Victor, do you have any opinion on this unicode filename issue? -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
STINNER Victor added the comment: Victor, do you have any opinion on this unicode filename issue? I closed the issue #11619 in january 2013 before there was no user requesting the feature. I just reopened the issue because users now ask for it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
Terry J. Reedy tjre...@udel.edu added the comment: My supposition that compile() rejects some real file names appears correct: from python-list ME: Is this a filename that could be an actual, valid filename on your system? OP: Yes it is. open works on that file. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13758] compile() should not encode 'filename' (at least on Windows)
New submission from Terry J. Reedy tjre...@udel.edu: The 3.2.2 doc for compile() says The filename argument should give the file from which the code was read; pass some recognizable value if it wasn’t read from a file ('string' is commonly used). I am not sure what 'recognizable' is supposed to mean, but as I understand it, it would be user-specific and any string containing a fake 'filename' should be accepted and attached to the output code object as the .co_filename attribute. (At least on Windows.) In fact, compile() has a hidden restriction: it encodes 'filename' with the local filesystem encoding. It tosses the bytes result (at least on Windows) but lets a UnicodeEncodeError terminate compilation. The effect is to add an undocumented and spurious dependency to code that has nothing to do with real files or the local machine. In #10114, msg118845, Victor Stinner justified this with co_filename attribute is used to display the traceback: Python opens the related file, read the source code line and display it. If the filename is fake, it cannot do that. (Perhaps the doc should warn users to make sure that fake filenames do not match any possibly real filenames ;-). The traceback mechanism could ignore UnicodeEncodeErrors just as well as it now ignores IO(?)Errors when open('fakename') does not not work. Victor continues On Windows, co_filename is directly used because Windows accepts unicode for filenames. This is not true in that on at least some Windows, compile tries to encode with the mbcs codec, which in turn uses the hidden local codepage. I believe that for most or all codepages, this will even raise errors for some valid Unicode filenames. I do not know whether the stored .co_filename attribute type for *nix is str, as on Windows, or bytes. If the latter, the doc should say so. If compile() continues to filter fake filenames, which I oppose, the doc should also say so and say what it does. This issue came up on python-list when someone used a Chinese filename and mbcs rejected it. -- components: Interpreter Core messages: 151034 nosy: terry.reedy priority: normal severity: normal stage: test needed status: open title: compile() should not encode 'filename' (at least on Windows) type: behavior versions: Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13758 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com