Message138625
| Author |
vinay.sajip |
| Recipients |
Arfrever, amaury.forgeotdarc, benjamin.peterson, georg.brandl, vinay.sajip |
| Date |
2011年06月19日.11:39:10 |
| SpamBayes Score |
7.06237e-07 |
| Marked as misclassified |
No |
| Message-id |
<1308483551.26.0.94674905556.issue12291@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 */ |
|