]> granicus.if.org Git - python/commitdiff
Replace PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 7 May 2010 16:34:53 +0000 (16:34 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 7 May 2010 16:34:53 +0000 (16:34 +0000)
"surrogateescape") by PyUnicode_DecodeFSDefault(val).

Modules/grpmodule.c
Modules/posixmodule.c
Modules/pwdmodule.c
Modules/spwdmodule.c

index 0dcef06c046161a6b9cc04715b31f9c16fe88161..912d1397045eb26ed86017dbcfb5907e321f9c8d 100644 (file)
@@ -46,11 +46,8 @@ mkgrent(struct group *p)
         Py_DECREF(v);
         return NULL;
     }
-#define FSDECODE(val) PyUnicode_Decode(val, strlen(val),\
-                                       Py_FileSystemDefaultEncoding,\
-                                       "surrogateescape")
     for (member = p->gr_mem; *member != NULL; member++) {
-        PyObject *x = FSDECODE(*member);
+        PyObject *x = PyUnicode_DecodeFSDefault(*member);
         if (x == NULL || PyList_Append(w, x) != 0) {
             Py_XDECREF(x);
             Py_DECREF(w);
@@ -61,13 +58,13 @@ mkgrent(struct group *p)
     }
 
 #define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
-    SET(setIndex++, FSDECODE(p->gr_name));
+    SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
 #ifdef __VMS
     SET(setIndex++, Py_None);
     Py_INCREF(Py_None);
 #else
     if (p->gr_passwd)
-           SET(setIndex++, FSDECODE(p->gr_passwd));
+           SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));
     else {
            SET(setIndex++, Py_None);
            Py_INCREF(Py_None);
index 0d6f8f05a61a5fb9fb196ce2735cc8810dfd03ed..a48f233da79641fcc0dff26fbcce768550d5e414 100644 (file)
@@ -2031,7 +2031,7 @@ posix_getcwd(int use_bytes)
         return posix_error();
     if (use_bytes)
         return PyBytes_FromStringAndSize(buf, strlen(buf));
-    return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"surrogateescape");
+    return PyUnicode_DecodeFSDefault(buf);
 }
 
 PyDoc_STRVAR(posix_getcwd__doc__,
index 1547cdf27aabb613221ea8141a5898a09772b951..827fa43d54b822708e89c62962e032a8c0f69295 100644 (file)
@@ -49,7 +49,7 @@ static void
 sets(PyObject *v, int i, const char* val)
 {
   if (val) {
-         PyObject *o = PyUnicode_Decode(val, strlen(val),
+         PyObject *o = PyUnicode_DecodeFSDefault(val, strlen(val),
                                         Py_FileSystemDefaultEncoding,
                                         "surrogateescape");
          PyStructSequence_SET_ITEM(v, i, o);
index 230b57cf3ea81a91395ab4e27cc9bbfaab664620..422ab033186fd2e8825a7e2ad808683240cad343 100644 (file)
@@ -60,9 +60,7 @@ static void
 sets(PyObject *v, int i, const char* val)
 {
   if (val) {
-         PyObject *o = PyUnicode_Decode(val, strlen(val),
-                                        Py_FileSystemDefaultEncoding,
-                                        "surrogateescape");
+         PyObject *o = PyUnicode_DecodeFSDefault(val);
          PyStructSequence_SET_ITEM(v, i, o);
   } else {
          PyStructSequence_SET_ITEM(v, i, Py_None);