This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: StringIO.StringIO, io.BytesIO, and io.StringIO accept None in places where other file-like objects don't
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, exarkun, pitrou, pjenvey
Priority: normal Keywords:

Created on 2009-11-18 19:01 by exarkun, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg95439 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-11-18 19:01
The actual file type rejects None in places like as the argument to read
or readlines.  StringIO.StringIO, io.BytesIO, and io.StringIO all accept
None to mean the same as passing no argument at all.

This makes it tricky to write code that might operate on any of these
types (as many APIs accepting a "file-like object" try to).  Testing
with one will not demonstrate that code works with any.  In particular,
it's common to start test with StringIO, which is more liberal, and only
discover a problem when code is run for real against an actual file.
msg95440 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-11-18 19:08
The original pure-python impl. of io accepted None, and still does. This 
is a regression in C impl.
msg96350 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-12-13 19:19
Fixed in r76805. I think I got all the cases...
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51598
2009-12-13 19:19:53benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg96350

resolution: fixed
2009-11-19 00:43:54r.david.murraysetnosy: + pitrou
2009-11-18 19:08:53pjenveysetnosy: + pjenvey
messages: + msg95440
2009-11-18 19:01:53exarkuncreate