Message223292
sys.stdin on 3.4.1 is also 'missing' (among public names) 'line_buffering' (True) and 'mode' ('r'). It seems that these could be trivially added, so the focus of this issue is 'buffer'. The associated
.detach method is a no-op, (It is also a bit dangerous for interactive operation.)
3.4.1 Console interpreter:
>>> import sys; b = sys.stdin.buffer.readline()
a line
>>> b
b'a line\r\n'
3.4.1 Idle:
>>> import sys; b = sys.stdin.buffer.readline()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import sys; b = sys.stdin.buffer.readline()
AttributeError: 'PseudoInputFile' object has no attribute 'buffer'
https://docs.python.org/3/library/sys.html#sys.stdin
presents the idiom. It also warns (too narrowly -- 'if you are writing a library ...') that it might not.
As far as I could find, the Idle doc does not mention the standard streams, let alone Idle specific limitations.
I intentionally wrote the title as a statement of a problematical situation, rather than as a proposed solution, as there are two: change code and change doc.
Code: add .buffer as a bytes-oriented Pseudofile.
Doc: at least mention that standard streams are replaced by objects that ship text between processes, and use gui for input and display, and the consiquences of this. |
|
Date |
User |
Action |
Args |
2014-07-16 22:47:30 | terry.reedy | set | recipients:
+ terry.reedy, docs@python |
2014-07-16 22:47:30 | terry.reedy | set | messageid: <1405550850.77.0.279876996055.issue21995@psf.upfronthosting.co.za> |
2014-07-16 22:47:30 | terry.reedy | link | issue21995 messages |
2014-07-16 22:47:30 | terry.reedy | create | |
|