[New-bugs-announce] [issue14447] marshal.load() reads entire remaining file instead of just next value

Matt Chaput report at bugs.python.org
Thu Mar 29 22:10:46 CEST 2012


New submission from Matt Chaput <matt at whoosh.ca>:

In Python 3.2, if you write several values to a file with multiple calls to marshal.dump(), and then try to read them back, the first marshal.load() returns the first value, but reads to the end of the file, so subsequent calls to marshal.load() raise an EOFError.

E.g.:

  import marshal
  f = open("test", "wb")
  marshal.dump(("hello", 1), f)
  marshal.dump(("there", 2), f)
  marshal.dump(("friend", 3), f)
  f.close()
  f = open("test", "rb")
  print(marshal.load(f))  # ('hello', 1)
  print(marshal.load(f))  # ERROR

This page seems to indicate this was also a bug in Python 3.1: http://www.velocityreviews.com/forums/t728526-python-3-1-2-and-marshal.html

----------
components: IO
messages: 157093
nosy: mattchaput
priority: normal
severity: normal
status: open
title: marshal.load() reads entire remaining file instead of just next value
type: behavior
versions: Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14447>
_______________________________________


More information about the New-bugs-announce mailing list