]> granicus.if.org Git - python/commitdiff
PyUnicode_DecodeFSDefaultAndSize() uses surrogateescape error handler
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 30 Apr 2010 16:37:52 +0000 (16:37 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 30 Apr 2010 16:37:52 +0000 (16:37 +0000)
This function is only used to decode Python module filenames, but Python
doesn't support surrogates in modules filenames yet. So nobody noticed this
minor bug.

Misc/NEWS
Objects/unicodeobject.c

index e1b011608ef653aa4b17d1d6420876deae2f71dd..b7e93182af283f9c3e679a6cd76a679504b6dc95 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 1?
 Core and Builtins
 -----------------
 
+- PyUnicode_DecodeFSDefaultAndSize() uses surrogateescape error handler
+
 - Issue #8419: Prevent the dict constructor from accepting non-string keyword
   arguments.
 
index 369306e368034b8e2379cf777fca5d1e45cbccfa..23b322f3043bcdc6f87a967d427799fa915eb5ed 100644 (file)
@@ -1600,19 +1600,19 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
     if (Py_FileSystemDefaultEncoding) {
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
         if (strcmp(Py_FileSystemDefaultEncoding, "mbcs") == 0) {
-            return PyUnicode_DecodeMBCS(s, size, "replace");
+            return PyUnicode_DecodeMBCS(s, size, "surrogateescape");
         }
 #elif defined(__APPLE__)
         if (strcmp(Py_FileSystemDefaultEncoding, "utf-8") == 0) {
-            return PyUnicode_DecodeUTF8(s, size, "replace");
+            return PyUnicode_DecodeUTF8(s, size, "surrogateescape");
         }
 #endif
         return PyUnicode_Decode(s, size,
                                 Py_FileSystemDefaultEncoding,
-                                "replace");
+                                "surrogateescape");
     }
     else {
-        return PyUnicode_DecodeUTF8(s, size, "replace");
+        return PyUnicode_DecodeUTF8(s, size, "surrogateescape");
     }
 }