Minor inconsistency between cStringIO and (StringIO or normal fil es)...

Mike Fletcher mfletch at tpresence.com
Fri Jan 21 21:31:49 EST 2000


Following demonstrates the inconsistency, essentially, a seek to maxint
raises a memory error on a cStringIO object, whereas the StringIO and file
objects just move to the end of the file for further actions (which is very
handy).  Is there a better way to spell "move to end of file" (keeping in
mind that this is for a class doing effectively random access in the
buffer)?

Cheers,
Mike

PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Portions Copyright 1994-1999 Mark Hammond (MHammond at simporkippinet.com.au)
>>> import cStringIO, sys
>>> d = cStringIO.StringIO()
>>> d.seek(sys.maxint)
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
MemoryError: 
>>> d = open( 'z:\\temp\\test.wrl','r')
>>> d.seek(sys.maxint)
>>> d.tell()
2147483647
>>> import StringIO
>>> d = StringIO.StringIO()
>>> d.seek(sys.maxint)
>>> d.tell()
2147483647
>>> 

__________________________________
 Mike C. Fletcher
 Designer, VR Plumber
 http://members.home.com/mcfletch




More information about the Python-list mailing list