[Python-checkins] cpython (2.7): socketmodule.c: backport INVALID_SOCKET from Python 3.5 to simplify the code
victor.stinner
python-checkins at python.org
Sat Jul 26 14:54:54 CEST 2014
http://hg.python.org/cpython/rev/a86c273a1270
changeset: 91880:a86c273a1270
branch: 2.7
parent: 91877:57e3c4ae37ea
user: Victor Stinner <victor.stinner at gmail.com>
date: Sat Jul 26 14:47:56 2014 +0200
summary:
socketmodule.c: backport INVALID_SOCKET from Python 3.5 to simplify the code
files:
Modules/socketmodule.c | 19 +++++--------------
1 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -94,6 +94,10 @@
#include "structmember.h"
#include "timefuncs.h"
+#ifndef INVALID_SOCKET /* MS defines this */
+#define INVALID_SOCKET (-1)
+#endif
+
#undef MAX
#define MAX(x, y) ((x) < (y) ? (y) : (x))
@@ -1705,11 +1709,7 @@
return NULL;
memset(&addrbuf, 0, addrlen);
-#ifdef MS_WINDOWS
newfd = INVALID_SOCKET;
-#else
- newfd = -1;
-#endif
if (!IS_SELECTABLE(s))
return select_error();
@@ -1727,11 +1727,7 @@
}
END_SELECT_LOOP(s)
-#ifdef MS_WINDOWS
if (newfd == INVALID_SOCKET)
-#else
- if (newfd < 0)
-#endif
return s->errorhandler();
/* Create the new object with unspecified family,
@@ -3185,12 +3181,7 @@
fd = socket(family, type, proto);
Py_END_ALLOW_THREADS
-#ifdef MS_WINDOWS
- if (fd == INVALID_SOCKET)
-#else
- if (fd < 0)
-#endif
- {
+ if (fd == INVALID_SOCKET) {
set_error();
return -1;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list