changeset: 97914:0c13674cf8b5 branch: 2.7 parent: 97902:77784422da4d user: Victor Stinner date: Fri Sep 11 12:42:13 2015 +0200 files: Misc/NEWS Modules/socketmodule.c description: Issue #24684: socket.socket.getaddrinfo() now calls PyUnicode_AsEncodedString() instead of calling the encode() method of the host, to handle correctly custom unicode string with an encode() method which doesn't return a byte string. The encoder of the IDNA codec is now called directly instead of calling the encode() method of the string. diff -r 77784422da4d -r 0c13674cf8b5 Misc/NEWS --- a/Misc/NEWS Fri Sep 11 03:58:30 2015 +0000 +++ b/Misc/NEWS Fri Sep 11 12:42:13 2015 +0200 @@ -37,6 +37,12 @@ Library ------- +- Issue #24684: socket.socket.getaddrinfo() now calls + PyUnicode_AsEncodedString() instead of calling the encode() method of the + host, to handle correctly custom unicode string with an encode() method + which doesn't return a byte string. The encoder of the IDNA codec is now + called directly instead of calling the encode() method of the string. + - Issue #24982: shutil.make_archive() with the "zip" format now adds entries for directories (including empty directories) in ZIP file. diff -r 77784422da4d -r 0c13674cf8b5 Modules/socketmodule.c --- a/Modules/socketmodule.c Fri Sep 11 03:58:30 2015 +0000 +++ b/Modules/socketmodule.c Fri Sep 11 12:42:13 2015 +0200 @@ -4158,7 +4158,7 @@ if (hobj == Py_None) { hptr = NULL; } else if (PyUnicode_Check(hobj)) { - idna = PyObject_CallMethod(hobj, "encode", "s", "idna"); + idna = PyUnicode_AsEncodedString(hobj, "idna", NULL); if (!idna) return NULL; hptr = PyString_AsString(idna);