[issue7348] StringIO.StringIO.readline(-1) returns the wrong result compared to other file-like objects

Terry J. Reedy report at bugs.python.org
Fri Nov 20 22:45:09 CET 2009


Terry J. Reedy <tjreedy at udel.edu> added the comment:

You specified neither version nor system.
On 3.1, Windows
>>> from io import StringIO as s
>>> s('a\nb\nfoo').readline(-1)

'a\n'

which, I gather, is what you describe as expected, although using -1 to
mean None is rather weird. 

The 3.1 doc says only 
"readline(limit=-1) 
Read and return one line from the stream. If limit is specified, at most
limit bytes will be read."
which would imply that negative numbers are the same as 0.

So even in 3.1, either the behavior is wrong or the doc is incomplete.

----------
nosy: +tjreedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7348>
_______________________________________


More information about the Python-bugs-list mailing list