From: Victor Stinner Date: Fri, 11 Sep 2015 10:42:13 +0000 (+0200) Subject: Issue #24684: socket.socket.getaddrinfo() now calls X-Git-Tag: v2.7.11rc1~159 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a2326b362055c18aed39f0ad8b86f05898733e7;p=thirdparty%2FPython%2Fcpython.git 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 --git a/Misc/NEWS b/Misc/NEWS index e17910854d04..f1b5ff951b4f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -37,6 +37,12 @@ Core and Builtins 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 --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 5def531c4a39..ced93433e57a 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4158,7 +4158,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args) 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);