[New-bugs-announce] [issue7349] StringIO.StringIO, io.BytesIO, and io.StringIO accept None in places where other file-like objects don't

Jean-Paul Calderone report at bugs.python.org
Wed Nov 18 20:01:54 CET 2009


New submission from Jean-Paul Calderone <exarkun at divmod.com>:

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.

----------
components: Library (Lib)
messages: 95439
nosy: exarkun
severity: normal
status: open
title: StringIO.StringIO, io.BytesIO, and io.StringIO accept None in places where other file-like objects don't

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


More information about the New-bugs-announce mailing list