Roundup Robot added the comment:
New changeset 4621bb82ceec by Antoine Pitrou in branch '3.4':
Issue #21364: remove recommendation of broken pattern.
http://hg.python.org/cpython/rev/4621bb82ceec
New changeset dbf728f9a2f0 by Antoine Pitrou in branch 'default':
Issue #21364: remove
Antoine Pitrou added the comment:
Thanks for the report, Armin. I've removed that recommendation and changed the
surrounding wording to insist that standard streams are always text streams.
--
resolution: - fixed
stage: - resolved
status: open - closed
Armin Ronacher added the comment:
To avoid further problems may I also recommend documenting how exactly people
are supposed to wrap sys.stdout and so forth. Clearly putting a StringIO there
is insufficient as StringIO does not have a buffer.
Something like this maybe?
import io
buf =
Antoine Pitrou added the comment:
To avoid further problems may I also recommend documenting how exactly
people are supposed to wrap sys.stdout and so forth. Clearly putting
a StringIO there is insufficient as StringIO does not have a buffer.
I would like to know of some situations where
Armin Ronacher added the comment:
I would like to know of some situations where you want to write some
code that accesses standard streams as binary *and* don't control the
application setup (i.e. library code rather than application code). It
seems to me that a library should take the
Armin Ronacher added the comment:
Pretty much, yes. Just that you probably want 'replace' instead.
surrogate-escape does not do anything useful here I think.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21364
Antoine Pitrou added the comment:
The same situations people wrapped streams before on python 2:
* code.py users. Werkzeug's traceback system implements a remote python
shell through it.
* any system that wants to unittest shell scripts on a high level.
* any system that wants to
R. David Murray added the comment:
Note that in 3.4 we have contextlib.replace_stdout, but it doesn't give any
examples of how to construct file-like objects that will work well with it.
--
___
Python tracker rep...@bugs.python.org
R. David Murray added the comment:
I mean redirect_stdout.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21364
___
___
Python-bugs-list mailing
R. David Murray added the comment:
The issue of (mixed) string and binary input/output on the standard streams is
still a bit of a work in progress, I think, both documentation wise and code
wise. So I'm not sure we know yet what the best practice is to recommend here.
I think I agree with
Armin Ronacher added the comment:
Sidestepping: The shutdown message is a related issue. TextIOWrapper tends to
internally log errors apparently which is super annoying and probably should be
fixed. I encountered the same problem with sockets disconnecting wrapped in
TextIOWrapper always
Martin Panter added the comment:
That particular revision isn’t sound so bad; I think the next revision,
78fb7f8cd349, which adds the make_streams_binary() function that replaces the
variables is a worry though.
This is the kind of code I use when I want to write binary data to stdout:
New submission from Armin Ronacher:
The documentation recommends replacing sys.stdin with a binary stream
currently: https://docs.python.org/3/library/sys.html#sys.stdin
This sounds like a bad idea because it will break pretty much everything in
Python in the process.
As example:
import
Changes by Florent Xicluna florent.xicl...@gmail.com:
--
components: +IO
nosy: +benjamin.peterson, flox, hynek, pitrou, stutzbach
type: - behavior
versions: +Python 3.3, Python 3.4, Python 3.5
___
Python tracker rep...@bugs.python.org
Antoine Pitrou added the comment:
Initial introduction is 59cb9c074e09.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21364
___
___
15 matches
Mail list logo