This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: SIZEOF_SOCKET_T used in longobject.h but undefined
Type: behavior Stage: needs patch
Components: Extension Modules Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: SIZEOF_SOCKET_T not defined
View: 4835
Assigned To: Nosy List: brian.curtin, christian.heimes, dmalcolm, pitrou, tim.golden
Priority: normal Keywords:

Created on 2010-08-17 18:50 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg114144 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 18:50
longobject.h uses SIZEOF_SOCKET_T:

#define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd))
#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLong(fd)
#define PyLong_FromSocket_t(fd) PyLong_FromLongLong(((SOCKET_T)(fd));
#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd)

but SIZEOF_SOCKET_T doesn't exist at that point since it is defined in Modules/socketmodule.h which isn't part of Include/Python.h. As a result, PyLong_FromSocket_t is always aliased to PyLong_FromLong, which is wrong under 64-bit Windows (a SOCKET is 64-bit there, while a long is 32-bit).
msg114145 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 18:55
This is witnessed in MSVC warning messages such as:

2>..\Modules\socketmodule.c(1611) : warning C4244: 'function' : conversion from 'SOCKET_T' to 'long', possible loss of data
msg114147 - (view) Author: Dave Malcolm (dmalcolm) (Python committer) Date: 2010-08-17 19:15
Looks like a dup of issue 4835
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53838
2010-08-17 19:17:23dmalcolmsetstatus: open -> closed
resolution: duplicate
superseder: SIZEOF_SOCKET_T not defined
2010-08-17 19:15:59dmalcolmsetnosy: + dmalcolm
messages: + msg114147
2010-08-17 18:55:51pitrousetmessages: + msg114145
2010-08-17 18:50:11pitroucreate