[Python-checkins] cpython (merge 3.3 -> default): (Merge 3.3) Close #18109: os.uname() now decodes fields from the locale

victor.stinner python-checkins at python.org
Mon Jun 3 22:15:09 CEST 2013


http://hg.python.org/cpython/rev/2472603af83e
changeset:   84020:2472603af83e
parent:      84018:46d8fea24490
parent:      84019:ffdee6b36305
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Jun 03 22:09:14 2013 +0200
summary:
  (Merge 3.3) Close #18109: os.uname() now decodes fields from the locale
encoding, and socket.gethostname() now decodes the hostname from the locale
encoding, instead of using the UTF-8 encoding in strict mode.

files:
  Misc/NEWS              |   6 +++++-
  Modules/posixmodule.c  |   2 +-
  Modules/socketmodule.c |  16 ++++++++--------
  3 files changed, 14 insertions(+), 10 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -103,6 +103,10 @@
 Library
 -------
 
+- Issue #18109: os.uname() now decodes fields from the locale encoding, and
+  socket.gethostname() now decodes the hostname from the locale encoding,
+  instead of using the UTF-8 encoding in strict mode.
+
 - Issue #18089: Implement importlib.abc.InspectLoader.load_module.
 
 - Issue #18088: Introduce importlib.abc.Loader.init_module_attrs for setting
@@ -416,7 +420,7 @@
 
 - Issue #15392: Create a unittest framework for IDLE.
   Initial patch by Rajagopalasarma Jayakrishnan.
-  
+
 - Issue #14146: Highlight source line while debugging on Windows.
 
 - Issue #17838: Allow sys.stdin to be reassigned.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4257,7 +4257,7 @@
 
 #define SET(i, field) \
     { \
-    PyObject *o = PyUnicode_DecodeASCII(field, strlen(field), NULL); \
+    PyObject *o = PyUnicode_DecodeFSDefault(field); \
     if (!o) { \
         Py_DECREF(value); \
         return NULL; \
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1644,7 +1644,7 @@
             return 0;
         }
 #endif
-            
+
 #ifdef PF_SYSTEM
     case PF_SYSTEM:
         switch (s->sock_proto) {
@@ -1652,10 +1652,10 @@
         case SYSPROTO_CONTROL:
         {
             struct sockaddr_ctl *addr;
-            
+
             addr = (struct sockaddr_ctl *)addr_ret;
             addr->sc_family = AF_SYSTEM;
-            addr->ss_sysaddr = AF_SYS_CONTROL; 
+            addr->ss_sysaddr = AF_SYS_CONTROL;
 
             if (PyUnicode_Check(args)) {
                 struct ctl_info info;
@@ -1681,17 +1681,17 @@
                           "cannot find kernel control with provided name");
                     return 0;
                 }
-                
+
                 addr->sc_id = info.ctl_id;
                 addr->sc_unit = 0;
             } else if (!PyArg_ParseTuple(args, "II",
                                          &(addr->sc_id), &(addr->sc_unit))) {
                 PyErr_SetString(PyExc_TypeError, "getsockaddrarg: "
                                 "expected str or tuple of two ints");
-                
+
                 return 0;
             }
-              
+
             *len_ret = sizeof(*addr);
             return 1;
         }
@@ -1808,7 +1808,7 @@
         return 1;
     }
 #endif
-            
+
 #ifdef PF_SYSTEM
     case PF_SYSTEM:
         switch(s->sock_proto) {
@@ -4048,7 +4048,7 @@
     if (res < 0)
         return set_error();
     buf[sizeof buf - 1] = '\0';
-    return PyUnicode_FromString(buf);
+    return PyUnicode_DecodeFSDefault(buf);
 #endif
 }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list