homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 */
History
Date User Action Args
2011年06月19日 11:39:11vinay.sajipsetrecipients: + vinay.sajip, georg.brandl, amaury.forgeotdarc, benjamin.peterson, Arfrever
2011年06月19日 11:39:11vinay.sajipsetmessageid: <1308483551.26.0.94674905556.issue12291@psf.upfronthosting.co.za>
2011年06月19日 11:39:10vinay.sajiplinkissue12291 messages
2011年06月19日 11:39:10vinay.sajipcreate

AltStyle によって変換されたページ (->オリジナル) /