Message138625
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 */ |
|
Date |
User |
Action |
Args |
2011-06-19 11:39:11 | vinay.sajip | set | recipients:
+ vinay.sajip, georg.brandl, amaury.forgeotdarc, benjamin.peterson, Arfrever |
2011-06-19 11:39:11 | vinay.sajip | set | messageid: <1308483551.26.0.94674905556.issue12291@psf.upfronthosting.co.za> |
2011-06-19 11:39:10 | vinay.sajip | link | issue12291 messages |
2011-06-19 11:39:10 | vinay.sajip | create | |
|