Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a534fc4

Browse files
committed
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.
1 parent caa00fe commit a534fc4

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

Misc/NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Core and Builtins
2424
Library
2525
-------
2626

27+
- Issue #18109: os.uname() now decodes fields from the locale encoding, and
28+
socket.gethostname() now decodes the hostname from the locale encoding,
29+
instead of using the UTF-8 encoding in strict mode.
30+
2731
- Issue #17403: urllib.parse.robotparser normalizes the urls before adding to
2832
ruleline. This helps in handling certain types invalid urls in a conservative
2933
manner.
@@ -69,7 +73,7 @@ IDLE
6973

7074
- Issue #15392: Create a unittest framework for IDLE.
7175
Initial patch by Rajagopalasarma Jayakrishnan.
72-
76+
7377
- Issue #14146: Highlight source line while debugging on Windows.
7478

7579
- Issue #17532: Always include Options menu for IDLE on OS X.

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4514,7 +4514,7 @@ posix_uname(PyObject *self, PyObject *noargs)
45144514

45154515
#define SET(i, field) \
45164516
{ \
4517-
PyObject *o = PyUnicode_DecodeASCII(field, strlen(field), NULL); \
4517+
PyObject *o = PyUnicode_DecodeFSDefault(field); \
45184518
if (!o) { \
45194519
Py_DECREF(value); \
45204520
return NULL; \

Modules/socketmodule.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,18 +1702,18 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
17021702
return 0;
17031703
}
17041704
#endif
1705-
1705+
17061706
#ifdef PF_SYSTEM
17071707
case PF_SYSTEM:
17081708
switch (s->sock_proto) {
17091709
#ifdef SYSPROTO_CONTROL
17101710
case SYSPROTO_CONTROL:
17111711
{
17121712
struct sockaddr_ctl *addr;
1713-
1713+
17141714
addr = (struct sockaddr_ctl *)addr_ret;
17151715
addr->sc_family = AF_SYSTEM;
1716-
addr->ss_sysaddr = AF_SYS_CONTROL;
1716+
addr->ss_sysaddr = AF_SYS_CONTROL;
17171717

17181718
if (PyUnicode_Check(args)) {
17191719
struct ctl_info info;
@@ -1739,17 +1739,17 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
17391739
"cannot find kernel control with provided name");
17401740
return 0;
17411741
}
1742-
1742+
17431743
addr->sc_id = info.ctl_id;
17441744
addr->sc_unit = 0;
17451745
} else if (!PyArg_ParseTuple(args, "II",
17461746
&(addr->sc_id), &(addr->sc_unit))) {
17471747
PyErr_SetString(PyExc_TypeError, "getsockaddrarg: "
17481748
"expected str or tuple of two ints");
1749-
1749+
17501750
return 0;
17511751
}
1752-
1752+
17531753
*len_ret = sizeof(*addr);
17541754
return 1;
17551755
}
@@ -1866,7 +1866,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
18661866
return 1;
18671867
}
18681868
#endif
1869-
1869+
18701870
#ifdef PF_SYSTEM
18711871
case PF_SYSTEM:
18721872
switch(s->sock_proto) {
@@ -4111,7 +4111,7 @@ socket_gethostname(PyObject *self, PyObject *unused)
41114111
if (res < 0)
41124112
return set_error();
41134113
buf[sizeof buf - 1] = '\0';
4114-
return PyUnicode_FromString(buf);
4114+
return PyUnicode_DecodeFSDefault(buf);
41154115
#endif
41164116
}
41174117

0 commit comments

Comments
 (0)