Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 052a04d

Browse files
author
Victor Stinner
committed
Revert r85435 (and r85440): decode command line arguments from utf-8
Python exits with a fatal error if the command line contains an undecodable argument. PyUnicode_FromString() fails at the first undecodable byte because it calls the error handler, but error handlers are not ready before Python initialization.
1 parent 59a289d commit 052a04d

2 files changed

Lines changed: 1 addition & 13 deletions

File tree

Misc/NEWS

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ What's New in Python 3.2 Beta 1?
1010
Core and Builtins
1111
-----------------
1212

13-
- Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of
14-
the locale encoding.
15-
1613
- Issue #9992: Remove PYTHONFSENCODING environment variable.
1714

1815
Library

Modules/python.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,10 @@ main(int argc, char **argv)
4141
oldloc = strdup(setlocale(LC_ALL, NULL));
4242
setlocale(LC_ALL, "");
4343
for (i = 0; i < argc; i++) {
44-
#ifdef __APPLE__
45-
/* Use utf-8 on Mac OS X */
46-
PyObject *unicode = PyUnicode_FromString(argv[i]);
47-
if (!unicode)
48-
return 1;
49-
argv_copy[i] = PyUnicode_AsWideCharString(unicode, NULL);
50-
Py_DECREF(unicode);
51-
#else
5244
argv_copy[i] = _Py_char2wchar(argv[i]);
53-
#endif
54-
argv_copy2[i] = argv_copy[i];
5545
if (!argv_copy[i])
5646
return 1;
47+
argv_copy2[i] = argv_copy[i];
5748
}
5849
setlocale(LC_ALL, oldloc);
5950
free(oldloc);

0 commit comments

Comments
 (0)