From: Victor Stinner Date: Thu, 2 Apr 2015 12:37:20 +0000 (+0200) Subject: Issue #23618: Fix sock_connect_impl(), set the socket error code X-Git-Tag: v3.5.0a4~198 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38aec7525eb22d2ea0090be610d6ababb4c8882f;p=thirdparty%2FPython%2Fcpython.git Issue #23618: Fix sock_connect_impl(), set the socket error code sock_call_ex() gets the socket error code when the socket function fails. sock_connect_impl() didn't set the error correctly. --- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d9fa04d0d644..81e9cc908fc4 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2589,7 +2589,13 @@ sock_connect_impl(PySocketSockObject *s, void* Py_UNUSED(data)) if (err == EISCONN) return 1; - return (err == 0); + if (err != 0) { + /* sock_call_ex() uses GET_SOCK_ERROR() to get the error code */ + SET_SOCK_ERROR(err); + abort(); + return 0; + } + return 1; } static int