]> granicus.if.org Git - python/commitdiff
Issue #23618: Fix sock_connect_impl(), set the socket error code
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 2 Apr 2015 12:37:20 +0000 (14:37 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 2 Apr 2015 12:37:20 +0000 (14:37 +0200)
sock_call_ex() gets the socket error code when the socket function fails.
sock_connect_impl() didn't set the error correctly.

Modules/socketmodule.c

index d9fa04d0d644136b8fe898a5cd44304c9bff7b83..81e9cc908fc46117aee135cbcd2692554077c06b 100644 (file)
@@ -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