[Python-bugs-list] [ python-Bugs-780354 ] socket.makefile() isn't compatible with marshal/cPickle/etc

SourceForge.net noreply@sourceforge.net
Fri, 01 Aug 2003 00:14:20 -0700


Bugs item #780354, was opened at 2003-07-30 19:02
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=780354&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: David M. Grimes (dmgrime)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.makefile() isn't compatible with marshal/cPickle/etc

Initial Comment:
Even on platforms where the underlying C libraries and associated 
code in
socketmodule.c support it, socket object's .makefile() method no 
longer
return "real" file objects.  This breaks support for cPickle, marshal, 
and
any other C modules which expect a file object as an argument.

The change initially appears in socket.py v1.36 - the changelog 
entry
states:

"""

The socket module now always uses the _socketobject wrapper 
class, even on
platforms which have dup(2).  The makefile() method is built directly 
on top
of the socket without duplicating the file descriptor, allowing timeouts 
to
work properly.  Includes a new test case (urllibnet) which requires 
the
network resource.

Closes bug 707074.
"""

I'm not sure of the implication WRT timeouts, but the patch is very 
small -
quite obviously removing the platform check which prevented the 
redefinition
of the symbol socket in the exports of socket.py.  It now is always 
the
_socketobject class, and not the underlying _socket.socket type 
(when it is
known the platform supports all functionality in _socket).

For now, I can workaround (since I don't need the timeout 
semantics) by
using _socket.socket() directly (I'm on a Linux platform), but I 
wondered if
this is something which can/should be addressed differently?



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-08-01 09:14

Message:
Logged In: YES 
user_id=21627

See the bug that this patch closes; I doubt there is an
alternative approach.

Instead, I think the C modules that expect file objects need
to be fixed.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=780354&group_id=5470