diff Modules/socketmodule.c @ 20805:076e5e49e27d 2.1

backport tim's 1.191: PySocketSock_connect_ex(): On Windows, return the correct Windows exit code. The patch is from Jeremy, and allows test_asynchat to run again.
author Anthony Baxter <anthonybaxter@gmail.com>
date Thu, 01 Nov 2001 14:00:11 +0000
parents 0629666e65c5
children 026bf0ab68a5
line wrap: on
line diff
--- a/Modules/socketmodule.c	Thu Nov 01 13:58:16 2001 +0000
+++ b/Modules/socketmodule.c	Thu Nov 01 14:00:11 2001 +0000
@@ -1108,8 +1108,13 @@
 	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);
 }