Created on 2009-11-18 18:58 by exarkun, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg95438 - (view) | Author: Jean-Paul Calderone (exarkun) * ![]() |
Date: 2009-11-18 18:58 | |
cStringIO and file both accept -1 to readline to mean the same thing as
not passing any argument at all. StringIO, on the other hand, gets
totally confused:
>>> from StringIO import StringIO
>>> StringIO('a\nb\nfoo').readline(-1)
'a\nb\nfo'
>>>
|
|||
| msg95568 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2009-11-20 21:45 | |
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.
|
|||
| msg95570 - (view) | Author: Jean-Paul Calderone (exarkun) * ![]() |
Date: 2009-11-20 21:47 | |
Python 2.6, Linux. |
|||
| msg96339 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2009-12-13 17:30 | |
Fixed in r76798. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:54 | admin | set | github: 51597 |
| 2009-12-13 17:30:12 | benjamin.peterson | set | status: open -> closed nosy:
+ benjamin.peterson resolution: fixed |
| 2009-11-20 21:47:12 | exarkun | set | messages: + msg95570 |
| 2009-11-20 21:45:08 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg95568 |
| 2009-11-18 18:58:35 | exarkun | create | |
