[issue12291] file written using marshal in 3.2 can be read by 2.7, but not 3.2 or 3.3

Vinay Sajip report at bugs.python.org
Sun Jun 19 17:43:11 CEST 2011


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

This seems a bit hacky, and I'm not sure how reliable it is. I added this after the read_object call:

    if (is_file) {
        PyObject * newpos;
        int cp, np;

        cp = ftell(rf.fp);
        newpos = PyObject_CallMethod(f, "seek", "ii", cp, SEEK_SET);
        assert(newpos != NULL);
        np = PyLong_AsLong(newpos);
        Py_DECREF(newpos);
        assert(cp == np);
    }

When I run the code lots of times, I sometimes get assertion failures at the

assert(newpos != NULL)

line. It's not an EOF condition thing, necessarily: I do get expected behaviour at least sometimes when seeking to the end of file.

----------

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


More information about the Python-bugs-list mailing list