[Python-bugs-list] [ python-Bugs-545446 ] cPickle problem with sockets (Windows)

noreply@sourceforge.net noreply@sourceforge.net
Wed, 17 Apr 2002 19:18:10 -0700


Bugs item #545446, was opened at 2002-04-18 01:03
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=545446&group_id=5470

>Category: Extension Modules
Group: None
>Status: Closed
>Resolution: Duplicate
Priority: 5
Submitted By: Michael Muller (mikemuller)
Assigned to: Nobody/Anonymous (nobody)
Summary: cPickle problem with sockets (Windows)

Initial Comment:
[someone found this bug in using one of my projects
(DOPY), I can not recreate it myself since I don't run
Windows.  I am reporting it second-hand based on having
narrowed it down to this via e-mail]

Apparently, under some circumstances when a socket
stream closes in Windows, a cPickle.Unpickler that is
reading from the stream reads a garbage character and
attempts to interpret it as a key, raising
"cPickle.UnpicklingError: invalid load key ' '" instead
of EOFError.

This behavior has been reproduced on both Windows 98SE
and Windows 2000.  It does not happen when the client
and server are running on the same computer.  It has
been observed to occur with the server running on
Windows and the client running on Linux.

The following server and client scripts can be used to
reproduce it:

server.py:
  import cPickle
  import socket

  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
  s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  s.bind(('', 9600))
  s.listen(5)
  c, addr = s.accept()

  src = cPickle.Unpickler(c.makefile('r'))

  first = src.load()

  # should raise EOFError
  try:
     second = src.load()
  except EOFError:
     pass

client.py:
  import cPickle
  import socket, sys

  s = socket.socket(socket.AF  _INET,
socket.SOCK_STREAM, 0)
  s.connect((sys.argv[1], 9600))

  dst = s.makefile('w')

  # send just one item
  cPickle.Pickler(dst).dump(100)

Note that this error does not occur with "pickle", only
cPickle.

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

>Comment By: Neil Schemenauer (nascheme)
Date: 2002-04-18 02:18

Message:
Logged In: YES 
user_id=35752

Duplicate of #523020.  Already fixed in CVS.

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

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