[issue21995] Idle: pseudofiles have no buffer attribute.
New submission from Terry J. Reedy: 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 "
", 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.
----------
assignee: docs@python
components: Documentation, IDLE
messages: 223292
nosy: docs@python, terry.reedy
priority: normal
severity: normal
stage: test needed
status: open
title: Idle: pseudofiles have no buffer attribute.
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5
_______________________________________
Python tracker
Roundup Robot added the comment:
New changeset ac6ade0c5927 by Terry Jan Reedy in branch '2.7':
Issue 21995: Explain some differences between IDLE and console Python.
https://hg.python.org/cpython/rev/ac6ade0c5927
New changeset ca6c9cc77c20 by Terry Jan Reedy in branch '3.4':
Issue 21995: Explain some differences between IDLE and console Python.
https://hg.python.org/cpython/rev/ca6c9cc77c20
----------
nosy: +python-dev
_______________________________________
Python tracker
Serhiy Storchaka added the comment:
https://docs.python.org/3/library/io.html#io.TextIOBase.buffer
"""buffer
The underlying binary buffer (a BufferedIOBase instance) that TextIOBase deals with. This is not part of the TextIOBase API and may not exist in some implementations."""
It is common to replace standard streams with StringIO.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker
Terry J. Reedy added the comment:
I believe this issue was derived from another were someone complained about something else being missing. I will just look into the other two and see if they are supposed to be there.
----------
_______________________________________
Python tracker
Terry J. Reedy added the comment:
Related #23220 has draft of part of what pushed. I want to do more on the subject.
----------
assignee: docs@python -> terry.reedy
_______________________________________
Python tracker
Serhiy Storchaka added the comment:
Yet one example of test stream that has no buffer - stdprinter used as sys.stderr on early stage of Python startup.
----------
_______________________________________
Python tracker
Terry J. Reedy
participants (3)
-
Roundup Robot
-
Serhiy Storchaka
-
Terry J. Reedy