New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac OS X: don't use the locale encoding but UTF-8 to encode and decode filenames #60620
Comments
Since the changeset 45079ad1e260 (issue bpo-4388), command line arguments are decoded from UTF-8 instead of the locale encoding. Functions of Python/fileutils.c are still using the locale encoding. It does not work: see issue bpo-16218. On Mac OS X, in the command line "python script.py", the filename "script.py" is decoded from UTF-8 (by _Py_DecodeUTF8_surrogateescape) but then it is passed to _Py_fopen() which encodes the filename to the locale encoding (ex: ISO-8859-1 if $LANG, $LC_CTYPE and $LC_ALL environment variables are not set). The result is mojibake and Python fails to open the script. Attached patch modifies function of Python/fileutils.c to use UTF-8 to encode and decode filenames, instead of the locale encoding on Mac OS X. I don't know yet if Module/getpath.c should also decode paths from UTF-8 instead of the locale encoding on Mac OS X. We may expose _Py_decode_filename(). |
macosx-2.patch patches _Py_wchar2char() and _Py_char2wchar() functions to -#ifdef __APPLE__
strlen(argv[i])); 2012/11/7 Andrew Svetlov <report@bugs.python.org>
|
New changeset 48fbdaf3a849 by Victor Stinner in branch 'default': |
New changeset f3e512b5ffb3 by Victor Stinner in branch 'default': |
New changeset 1b97cc71a05e by Victor Stinner in branch 'default': |
@serhiy: Thanks for your review, I missed it before my first commit. |
Victor, are you going to backport this to 3.3? |
I'm waiting for the result of the buildbots, and maybe also the fix for the issue bpo-16455 (which has an impact on tests on undecodable bytes). |
Victor, could you please backport to 3.3? |
Ping. |
New changeset c838c9b117f1 by Victor Stinner in branch '3.2': New changeset 26c4748351cb by Victor Stinner in branch '3.3': |
New changeset af6fd3ca6de9 by Victor Stinner in branch '3.2': |
The issue should now be fixed in Python 3.2, 3.3 and 3.4. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: