win32all140 - PySocket_AsSocket fails for Python 2.2 socket objects

Alan Klietz alank at NOSPAM.com
Sun Jan 6 10:54:34 CET 2002


PySocket_AsSocket locates an objects fileno() member and calls it to extract
the underlying file descriptor for a socket object by doing a
PyInstance_Check().  However, in Python 2.2 a socket is a new-style object,
which fails the test.

PyWinTypesModule.cpp
*************** BOOL PySocket_AsSOCKET
*** 66,72 ****
   {
    *ps = (SOCKET)PyInt_AS_LONG(obSocket);
   }
!  else if (PyInstance_Check(obSocket))
   {
    o = PyObject_GetAttrString(obSocket, "fileno");
    if (o == NULL)
--- 66,72 ----
   {
    *ps = (SOCKET)PyInt_AS_LONG(obSocket);
   }
!  else /*if (PyInstance_Check(obSocket)) BUG: _socket is intrinsic - AEK */
   {
    o = PyObject_GetAttrString(obSocket, "fileno");
    if (o == NULL)

Alan Klietz
alank at algintech.NOSPAM.com  (remove .NOSPAM)






More information about the Python-list mailing list