Vinay Sajip <[email protected]> added the comment:
The problem with calling fileno() and fdopen() is that you bypass the buffering
information held in BufferedIOReader. The first call works, but the FILE *
pointer is now positioned at 4K, rather than just past the end of the object
just read. The next call fails.
I verified that calling f.tell() after marshal.load(f) returns 4096, rather
than just the size of the object read by the load().
Just to be clear, here's what I did in marshal_load:
int is_file = 0;
int fd;
data = PyObject_CallMethod(f, "fileno", "");
if (data == NULL)
PyErr_Clear();
else {
fd = PyLong_AsLong(data);
Py_DECREF(data);
is_file = 1;
}
if (is_file) {
rf.readable = NULL;
rf.fp = fdopen(fd, "rb");
}
else {
/* what I was doing before to set up rf */
}
/* and on to the read_object call */
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12291>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com