[pypy-dev] _marshal EOF error?
jonathan at slenders.be
Wed Aug 8 23:27:01 CEST 2012
I have almost a sandlib.py library ready for the Twisted Matrix framework.
(The sandlib which is shipped with PyPy is not usable within Twisted.)
However, the deserialisation of marshalled messages fails when the sandbox
Python process does very big write system calls. Actually, the problem is
that the write calls arrive in multiple chunks in the outReceived of the
ProcessProtocol (Twisted code). Marshal.loads thinks the first chunk is
valid on its own while it isn't yet.
Long story short, there is a difference between the Python built-in and the
pure python _marshall.py from PyPy which should be used for the sandbox
hypervisor. It should throw EOF when a string-object is truncated, while it
>>> import _marshal # lib_pypy/_marshal.py
(3, '\n<stations version="1.1" ')
>>> import marshal # Python built-in
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
EOFError: EOF read where object expected
The patch, just add this one line to lib_pypy/_marshal.py (line 433)
def _read(self, n):
pos = self.bufpos
newpos = pos + n
* if newpos > len(self.bufstr): raise EOFError*
ret = self.bufstr[pos : newpos]
self.bufpos = newpos
This is the first bug that I found. Should I create a bug report or patch
file for this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pypy-dev