[Python-checkins] r85442 - in python/branches/py3k: Misc/NEWS Modules/python.c

victor.stinner python-checkins at python.org
Thu Oct 14 01:24:06 CEST 2010


Author: victor.stinner
Date: Thu Oct 14 01:24:06 2010
New Revision: 85442

Log:
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.


Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/python.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu Oct 14 01:24:06 2010
@@ -10,9 +10,6 @@
 Core and Builtins
 -----------------
 
-- Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of
-  the locale encoding.
-
 - Issue #9992: Remove PYTHONFSENCODING environment variable.
 
 Library

Modified: python/branches/py3k/Modules/python.c
==============================================================================
--- python/branches/py3k/Modules/python.c	(original)
+++ python/branches/py3k/Modules/python.c	Thu Oct 14 01:24:06 2010
@@ -41,19 +41,10 @@
     oldloc = strdup(setlocale(LC_ALL, NULL));
     setlocale(LC_ALL, "");
     for (i = 0; i < argc; i++) {
-#ifdef __APPLE__
-        /* Use utf-8 on Mac OS X */
-        PyObject *unicode = PyUnicode_FromString(argv[i]);
-        if (!unicode)
-            return 1;
-        argv_copy[i] = PyUnicode_AsWideCharString(unicode, NULL);
-        Py_DECREF(unicode);
-#else
         argv_copy[i] = _Py_char2wchar(argv[i]);
-#endif
-        argv_copy2[i] = argv_copy[i];
         if (!argv_copy[i])
             return 1;
+        argv_copy2[i] = argv_copy[i];
     }
     setlocale(LC_ALL, oldloc);
     free(oldloc);


More information about the Python-checkins mailing list