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.
This commit is contained in:
Victor Stinner 2013-06-03 22:07:27 +02:00
parent caa00fec19
commit a534fc4b3b
3 changed files with 14 additions and 10 deletions

View File

@ -24,6 +24,10 @@ Core and Builtins
Library 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 #17403: urllib.parse.robotparser normalizes the urls before adding to - Issue #17403: urllib.parse.robotparser normalizes the urls before adding to
ruleline. This helps in handling certain types invalid urls in a conservative ruleline. This helps in handling certain types invalid urls in a conservative
manner. manner.
@ -69,7 +73,7 @@ IDLE
- Issue #15392: Create a unittest framework for IDLE. - Issue #15392: Create a unittest framework for IDLE.
Initial patch by Rajagopalasarma Jayakrishnan. Initial patch by Rajagopalasarma Jayakrishnan.
- Issue #14146: Highlight source line while debugging on Windows. - Issue #14146: Highlight source line while debugging on Windows.
- Issue #17532: Always include Options menu for IDLE on OS X. - Issue #17532: Always include Options menu for IDLE on OS X.

View File

@ -4514,7 +4514,7 @@ posix_uname(PyObject *self, PyObject *noargs)
#define SET(i, field) \ #define SET(i, field) \
{ \ { \
PyObject *o = PyUnicode_DecodeASCII(field, strlen(field), NULL); \ PyObject *o = PyUnicode_DecodeFSDefault(field); \
if (!o) { \ if (!o) { \
Py_DECREF(value); \ Py_DECREF(value); \
return NULL; \ return NULL; \

View File

@ -1702,7 +1702,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
return 0; return 0;
} }
#endif #endif
#ifdef PF_SYSTEM #ifdef PF_SYSTEM
case PF_SYSTEM: case PF_SYSTEM:
switch (s->sock_proto) { switch (s->sock_proto) {
@ -1710,10 +1710,10 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
case SYSPROTO_CONTROL: case SYSPROTO_CONTROL:
{ {
struct sockaddr_ctl *addr; struct sockaddr_ctl *addr;
addr = (struct sockaddr_ctl *)addr_ret; addr = (struct sockaddr_ctl *)addr_ret;
addr->sc_family = AF_SYSTEM; addr->sc_family = AF_SYSTEM;
addr->ss_sysaddr = AF_SYS_CONTROL; addr->ss_sysaddr = AF_SYS_CONTROL;
if (PyUnicode_Check(args)) { if (PyUnicode_Check(args)) {
struct ctl_info info; struct ctl_info info;
@ -1739,17 +1739,17 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
"cannot find kernel control with provided name"); "cannot find kernel control with provided name");
return 0; return 0;
} }
addr->sc_id = info.ctl_id; addr->sc_id = info.ctl_id;
addr->sc_unit = 0; addr->sc_unit = 0;
} else if (!PyArg_ParseTuple(args, "II", } else if (!PyArg_ParseTuple(args, "II",
&(addr->sc_id), &(addr->sc_unit))) { &(addr->sc_id), &(addr->sc_unit))) {
PyErr_SetString(PyExc_TypeError, "getsockaddrarg: " PyErr_SetString(PyExc_TypeError, "getsockaddrarg: "
"expected str or tuple of two ints"); "expected str or tuple of two ints");
return 0; return 0;
} }
*len_ret = sizeof(*addr); *len_ret = sizeof(*addr);
return 1; return 1;
} }
@ -1866,7 +1866,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
return 1; return 1;
} }
#endif #endif
#ifdef PF_SYSTEM #ifdef PF_SYSTEM
case PF_SYSTEM: case PF_SYSTEM:
switch(s->sock_proto) { switch(s->sock_proto) {
@ -4111,7 +4111,7 @@ socket_gethostname(PyObject *self, PyObject *unused)
if (res < 0) if (res < 0)
return set_error(); return set_error();
buf[sizeof buf - 1] = '\0'; buf[sizeof buf - 1] = '\0';
return PyUnicode_FromString(buf); return PyUnicode_DecodeFSDefault(buf);
#endif #endif
} }