StringIO readline() bug??
Chris Arai
chris at araidesign.com
Fri Oct 13 04:49:06 EDT 2000
Hello,
I'm new to python, but I think I have found a bug in StringIO. In any
case I'm having a problem.
readline() on a StringIO object crashes with an attribute error:
>>> fstr.readline()
Traceback (innermost last):
File "<pyshell#37>", line 1, in ?
fstr.readline()
File "/usr/lib/python1.6/StringIO.py", line 83, in readline
i = string.find(self.buf, '\n', self.pos)
File "/usr/lib/python1.6/string.py", line 171, in find
return _apply(s.find, args)
AttributeError: find
The history is that:
1 . I opened a text file
>>>file=open("legalfilename",'r')
2. then I scoop that file's text into a StringIO object:
>>>fstr=StringIO(file.readlines())
3. This seems that this work because
>>>fstr.getvalue() #prints all the text to console
>>>file.readlines() # does the same
>>>file.readlines()==fstr.getvalue() #returns a 1
>>>file.readline() #returns one line
>>>fstr.readline() #crashes, with the above message
Is it a bug or am I doing something incorrectly??
I'm running Python 1.6.
Thanks,
Chris
More information about the Python-list
mailing list