[Python-checkins] r80923 - in python/branches/py3k/Modules: grpmodule.c posixmodule.c pwdmodule.c spwdmodule.c

victor.stinner python-checkins at python.org
Fri May 7 18:34:53 CEST 2010


Author: victor.stinner
Date: Fri May  7 18:34:53 2010
New Revision: 80923

Log:
Replace PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,
"surrogateescape") by PyUnicode_DecodeFSDefault(val).


Modified:
   python/branches/py3k/Modules/grpmodule.c
   python/branches/py3k/Modules/posixmodule.c
   python/branches/py3k/Modules/pwdmodule.c
   python/branches/py3k/Modules/spwdmodule.c

Modified: python/branches/py3k/Modules/grpmodule.c
==============================================================================
--- python/branches/py3k/Modules/grpmodule.c	(original)
+++ python/branches/py3k/Modules/grpmodule.c	Fri May  7 18:34:53 2010
@@ -46,11 +46,8 @@
         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 @@
     }
 
 #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);

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Fri May  7 18:34:53 2010
@@ -2031,7 +2031,7 @@
         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__,

Modified: python/branches/py3k/Modules/pwdmodule.c
==============================================================================
--- python/branches/py3k/Modules/pwdmodule.c	(original)
+++ python/branches/py3k/Modules/pwdmodule.c	Fri May  7 18:34:53 2010
@@ -49,7 +49,7 @@
 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);

Modified: python/branches/py3k/Modules/spwdmodule.c
==============================================================================
--- python/branches/py3k/Modules/spwdmodule.c	(original)
+++ python/branches/py3k/Modules/spwdmodule.c	Fri May  7 18:34:53 2010
@@ -60,9 +60,7 @@
 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);


More information about the Python-checkins mailing list