This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Idle: review 'missing' attributes of pseudofiles
Type: enhancement Stage: test needed
Components: Documentation, IDLE Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: docs@python, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2014-07-16 22:47 by terry.reedy, last changed 2022-04-11 14:58 by admin.

Messages (7)
msg223292 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-07-16 22:47
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.
msg251492 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-24 07:10
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
msg251496 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-24 07:24
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.
msg251505 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-24 10:39
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.
msg251824 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-29 06:43
Related #23220 has draft of part of what pushed.  I want to do more on the subject.
msg252013 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-10-01 09:33
Yet one example of test stream that has no buffer - stdprinter used as sys.stderr on early stage of Python startup.
msg359556 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-01-07 22:29
I changed title to 'review' (TextIOBase doc and StringIO as a pure text implementation).
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66194
2020-01-07 22:29:45terry.reedysettitle: Idle: pseudofiles have no buffer attribute. -> Idle: review 'missing' attributes of pseudofiles
messages: + msg359556
versions: + Python 3.9, - Python 2.7, Python 3.4, Python 3.5
2015-10-01 09:33:09serhiy.storchakasetmessages: + msg252013
2015-09-29 06:43:12terry.reedysetassignee: docs@python -> terry.reedy
messages: + msg251824
2015-09-24 10:39:50terry.reedysetmessages: + msg251505
2015-09-24 07:24:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg251496
2015-09-24 07:10:28python-devsetnosy: + python-dev
messages: + msg251492
2014-07-16 22:47:30terry.reedycreate