]> granicus.if.org Git - python/commitdiff
Use PyUnicode_EncodeCodePage() instead of PyUnicode_EncodeMBCS() with
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 20 Nov 2011 17:27:03 +0000 (18:27 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 20 Nov 2011 17:27:03 +0000 (18:27 +0100)
PyUnicode_AsUnicodeAndSize()

Objects/unicodeobject.c

index b0b9528be57de14a56ab3bdda3ce58a1d8841823..90a4fcb62fbbf9683df1bdf913c8e4e3a9c95653 100644 (file)
@@ -3051,13 +3051,7 @@ PyObject *
 PyUnicode_EncodeFSDefault(PyObject *unicode)
 {
 #ifdef HAVE_MBCS
-    const Py_UNICODE *wstr;
-    Py_ssize_t wlen;
-
-    wstr = PyUnicode_AsUnicodeAndSize(unicode, &wlen);
-    if (wstr == NULL)
-        return NULL;
-    return PyUnicode_EncodeMBCS(wstr, wlen, NULL);
+    return PyUnicode_EncodeCodePage(CP_ACP, unicode, NULL);
 #elif defined(__APPLE__)
     return _PyUnicode_AsUTF8String(unicode, "surrogateescape");
 #else
@@ -3141,15 +3135,8 @@ PyUnicode_AsEncodedString(PyObject *unicode,
                  (strcmp(lower, "iso-8859-1") == 0))
             return _PyUnicode_AsLatin1String(unicode, errors);
 #ifdef HAVE_MBCS
-        else if (strcmp(lower, "mbcs") == 0) {
-            const Py_UNICODE *wstr;
-            Py_ssize_t wlen;
-
-            wstr = PyUnicode_AsUnicodeAndSize(unicode, &wlen);
-            if (wstr == NULL)
-                return NULL;
-            return PyUnicode_EncodeMBCS(wstr, wlen, errors);
-        }
+        else if (strcmp(lower, "mbcs") == 0)
+            return PyUnicode_EncodeCodePage(CP_ACP, unicode, errors);
 #endif
         else if (strcmp(lower, "ascii") == 0)
             return _PyUnicode_AsASCIIString(unicode, errors);