[issue22709] restore accepting detached stdin in fileinput binary mode
Serhiy Storchaka
report at bugs.python.org
Thu Oct 23 13:49:35 CEST 2014
Serhiy Storchaka added the comment:
> It is incorrect that sys.stdin is *always* a text stream. It often is,
> but not always.
>
> There are cases when it is not e.g.,
>
> $ tar zcf - stuff | gpg -e | ssh user at server 'cat - > stuff.tar.gz.gpg'
>
> tar's stdout is *not* a text stream.
> gpg's stdin/stdout are *not* text streams.
> ssh's stdin is *not* a text stream.
> etc.
This is not related to Python. Terms "character", "string", "text", "file" can
have different meaning in different domains. In Python we use Python
terminology. There is no such thing as sys.stdin in Posix-compatible shell,
because Posix-compatible shell has no the sys module and doesn't use a dot to
access attributes.
> Any script written before Python 3.4.1 (#21075) that used FileInput binary
> mode *had to* use sys.stdin = sys.stdin.detach()
>
> A bugfix release should not break working code.
Correct solution in this case would be to use the workaround "sys.stdin =
sys.stdin.detach()" conditionally, only in Python versions which have a bug.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22709>
_______________________________________
More information about the Python-bugs-list
mailing list