]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport tim's 1.191:
authorAnthony Baxter <anthonybaxter@gmail.com>
Thu, 1 Nov 2001 14:00:11 +0000 (14:00 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Thu, 1 Nov 2001 14:00:11 +0000 (14:00 +0000)
  PySocketSock_connect_ex():  On Windows, return the correct Windows exit
  code.  The patch is from Jeremy, and allows test_asynchat to run again.

Modules/socketmodule.c

index c2e38804e81f0d1c21ce3015012b4fe9e68afd72..083676684728b03f07d6a168e3f67c6db1fc7679 100644 (file)
@@ -1108,8 +1108,13 @@ PySocketSock_connect_ex(PySocketSockObject *s, PyObject *args)
        Py_BEGIN_ALLOW_THREADS
        res = connect(s->sock_fd, addr, addrlen);
        Py_END_ALLOW_THREADS
-       if (res != 0)
+       if (res != 0) {
+#ifdef MS_WINDOWS
+               res = WSAGetLastError();
+#else
                res = errno;
+#endif
+       }
        return PyInt_FromLong((long) res);
 }