diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-11 10:37:30 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-11 10:37:30 (GMT) |
commit | ec1a498a01da2b4df22413ff778529d84111c2ee (patch) | |
tree | 819f96f6bba39e4d1a3f01c0c909617d2e91b31a /Modules/socketmodule.c | |
parent | db4220ea09c2a36b3eb7edbde40b356c9caad10d (diff) | |
download | cpython-ec1a498a01da2b4df22413ff778529d84111c2ee.zip cpython-ec1a498a01da2b4df22413ff778529d84111c2ee.tar.gz cpython-ec1a498a01da2b4df22413ff778529d84111c2ee.tar.bz2 |
Issue #24684: socket.socket.getaddrinfo() now calls
PyUnicode_AsEncodedString() instead of calling the encode() method of the
host, to handle correctly custom 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.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index b6f2bf5..23019ee 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5213,9 +5213,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) if (hobj == Py_None) { hptr = NULL; } else if (PyUnicode_Check(hobj)) { - _Py_IDENTIFIER(encode); - - idna = _PyObject_CallMethodId(hobj, &PyId_encode, "s", "idna"); + idna = PyUnicode_AsEncodedString(hobj, "idna", NULL); if (!idna) return NULL; assert(PyBytes_Check(idna)); |