From b440aec9f943a422b05353812be851100253d667 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 28 Aug 2010 20:53:24 +0000 Subject: [PATCH] Merged revisions 84347 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ........ r84347 | antoine.pitrou | 2010-08-28 22:42:55 +0200 (sam., 28 août 2010) | 5 lines Issue #4835: make PyLong_FromSocket_t() and PyLong_AsSocket_t() private to the socket module, and fix the width of socket descriptors to be correctly detected under 64-bit Windows. ........ --- Include/longobject.h | 9 --------- Misc/NEWS | 4 ++++ Modules/socketmodule.h | 8 ++++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Include/longobject.h b/Include/longobject.h index 28fb707aa8..6e4e1a4e9b 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -32,15 +32,6 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); cleanup to keep the extra information. [CH] */ #define PyLong_AS_LONG(op) PyLong_AsLong(op) -/* Used by socketmodule.c */ -#if SIZEOF_SOCKET_T <= SIZEOF_LONG -#define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd)) -#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLong(fd) -#else -#define PyLong_FromSocket_t(fd) PyLong_FromLongLong(((SOCKET_T)(fd)); -#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd) -#endif - /* For use by intobject.c only */ PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; diff --git a/Misc/NEWS b/Misc/NEWS index 5075c3866e..0ff6fa0eaa 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -463,6 +463,10 @@ Library Extension Modules ----------------- +- Issue #4835: make PyLong_FromSocket_t() and PyLong_AsSocket_t() private + to the socket module, and fix the width of socket descriptors to be + correctly detected under 64-bit Windows. + - Issue #665761: ``functools.reduce()`` will no longer mask exceptions other than ``TypeError`` raised by the iterator argument. diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h index 49ac9d02a1..4f426f5d85 100644 --- a/Modules/socketmodule.h +++ b/Modules/socketmodule.h @@ -93,6 +93,14 @@ typedef int SOCKET_T; # define SIZEOF_SOCKET_T SIZEOF_INT #endif +#if SIZEOF_SOCKET_T <= SIZEOF_LONG +#define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd)) +#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLong(fd) +#else +#define PyLong_FromSocket_t(fd) PyLong_FromLongLong((SOCKET_T)(fd)) +#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd) +#endif + /* Socket address */ typedef union sock_addr { struct sockaddr_in in; -- 2.40.0