[docs] [issue20501] fileinput module will read whole file into memory when using fileinput.hook_encoded

Serhiy Storchaka report at bugs.python.org
Fri Feb 28 22:26:12 CET 2014


Serhiy Storchaka added the comment:

My bad. I had cleaned patch before committing to 3.x, but forgot to revert and correct it in 2.7. Thank you Vajrasky an Zachary.

> Does it mean: "UTF-7 is an unlikely locale encoding"?

Sorry for my bad English. I meant that UTF-7 is used here because it is unlikely that it is locale encoding. Is "an" needed here?

> I would actually vote for using writeTmp, and make a new issue for making writeTmp use a context manager.

I think that explicit two-line code is better than calling superfluous function. We don't need generated filename, we write only one chunk of code, we use context manager, so the code is only two lines long.

> inside a `try ... except UnicodeDecodeError: self.fail('Read to end of file')` block.

May be, but in 2.7 a traceback doesn't contain info about original exception and this can hide necessary details in case of failure.

----------

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


More information about the docs mailing list