[qmtest] PATCH: Make PickleResultReader handle StringIO files

Mark Mitchell mark at codesourcery.com
Mon Sep 29 00:09:22 UTC 2003


On Sun, 2003-09-28 at 16:33, Nathaniel Smith wrote:
> On Sun, Sep 28, 2003 at 04:04:53PM -0700, Mark Mitchell wrote:
> > When the ResultReader abstraction was created, this code (which was in
> > load_outcomes) did not get moved into the PickleResultReader class. 
> > Nathaniel, did you make this change purposefully, or was it just an
> > accident?
> 
> I made it on purpose.  The old code treated both 'EOFError's and
> 'UnpickleableError's as marking end-of-file, with a comment that the
> latter was required because of buggy interaction between cPickle and
> cStringIO.  I checked with a 2.2 interpreter, and found that this
> buggy interaction didn't occur.  Just now:
> 
> ~$ python2.2
> Python 2.2.3 (#1, Jun  4 2003, 02:54:59) 
> [GCC 3.3 (Debian)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import cStringIO

Actually, I don't think this is a version thing -- it's a StringIO vs.
cStringIO thing.  Your test code works fine with Python 2.2.1 on my Red
Hat 9 box -- but not if you replace cStringIO with StringIO.

We could use cStringIO internally -- but we've got no good way to
prevent users from wanting to use StringIO themselves, so I think we
still need the compensation code in PickleResultReader.  I'm not sure
why StringIO doesn't sythesize the EOFError exception; that may be a
misfeature in the Python library.

-- 
Mark Mitchell <mark at codesourcery.com>
CodeSourcery, LLC




More information about the qmtest mailing list