[New-bugs-announce] [issue21075] fileinput should use stdin.buffer for "rb" mode

Brandon Rhodes report at bugs.python.org
Thu Mar 27 14:42:43 CET 2014


New submission from Brandon Rhodes:

In Python 3, fileinput.input() returns str lines whether the data is
coming from stdin or from a list of files on the command line. But if
input(mode='rb') is specified, then its behavior becomes inconsistent:
lines from stdin are delivered as already-decoded strings, but data
from files is delivered (correctly) as bytes.

The solution may be that, if a "b" is anywhere in the mode, then input()
should read from the bytes stdin.buffer data source instead of from
stdin.

Otherwise the "rb" mode is rather useless since you can wind
up getting text from it anyway depending on how you are invoked.

----------
components: Library (Lib)
messages: 214952
nosy: brandon-rhodes
priority: normal
severity: normal
status: open
title: fileinput should use stdin.buffer for "rb" mode
type: behavior
versions: Python 3.4

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


More information about the New-bugs-announce mailing list