_marshal EOF error?
Hi everyone, 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 doesn't.
import _marshal # lib_pypy/_marshal.py
_marshal.loads('(\x02\x00\x00\x00i\x03\x00\x00\x00sB\xf9\x00\x00\n<stations version="1.1" ') (3, '\n<stations version="1.1" ')
import marshal # Python built-in
marshal.loads('(\x02\x00\x00\x00i\x03\x00\x00\x00sB\xf9\x00\x00\n<stations version="1.1" ') 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 return ret This is the first bug that I found. Should I create a bug report or patch file for this? Thanks, Jonathan Slenders
Hi Jonathan, On Wed, Aug 8, 2012 at 11:27 PM, Jonathan Slenders <jonathan@slenders.be> wrote:
The patch, just add this one line to lib_pypy/_marshal.py (line 433)
Thanks! Checked in this extra line together with a 2-line test in lib_pypy/pypy_test/test_marshal_extra.py. For larger changes or ones that are not so "obviously correct", you would need to submit either a patch to the bug tracker https://bugs.pypy.org/ , or a pull request on bitbucket if you are familiar with "hg". A bientôt, Armin.
Merci Armin! Keep up the great work! 2012/8/9 Armin Rigo <arigo@tunes.org>
Hi Jonathan,
On Wed, Aug 8, 2012 at 11:27 PM, Jonathan Slenders <jonathan@slenders.be> wrote:
The patch, just add this one line to lib_pypy/_marshal.py (line 433)
Thanks! Checked in this extra line together with a 2-line test in lib_pypy/pypy_test/test_marshal_extra.py.
For larger changes or ones that are not so "obviously correct", you would need to submit either a patch to the bug tracker https://bugs.pypy.org/ , or a pull request on bitbucket if you are familiar with "hg".
A bientôt,
Armin.
participants (2)
-
Armin Rigo
-
Jonathan Slenders