Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idle: review 'missing' attributes of pseudofiles #66194

Open
terryjreedy opened this issue Jul 16, 2014 · 7 comments
Open

Idle: review 'missing' attributes of pseudofiles #66194

terryjreedy opened this issue Jul 16, 2014 · 7 comments
Assignees
Labels
3.9 only security fixes docs Documentation in the Doc dir topic-IDLE type-feature A feature request or enhancement

Comments

@terryjreedy
Copy link
Member

BPO 21995
Nosy @terryjreedy, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/terryjreedy'
closed_at = None
created_at = <Date 2014-07-16.22:47:30.742>
labels = ['expert-IDLE', 'type-feature', '3.9', 'docs']
title = "Idle: review 'missing' attributes of pseudofiles"
updated_at = <Date 2020-01-07.22:29:45.724>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2020-01-07.22:29:45.724>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = False
closed_date = None
closer = None
components = ['Documentation', 'IDLE']
creation = <Date 2014-07-16.22:47:30.742>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 21995
keywords = []
message_count = 7.0
messages = ['223292', '251492', '251496', '251505', '251824', '252013', '359556']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'docs@python', 'python-dev', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue21995'
versions = ['Python 3.9']

@terryjreedy
Copy link
Member Author

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.

@terryjreedy terryjreedy added docs Documentation in the Doc dir topic-IDLE type-feature A feature request or enhancement labels Jul 16, 2014
@python-dev
Copy link
Mannequin

python-dev mannequin commented Sep 24, 2015

New changeset ac6ade0c5927 by Terry Jan Reedy in branch '2.7':
bpo-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':
bpo-21995: Explain some differences between IDLE and console Python.
https://hg.python.org/cpython/rev/ca6c9cc77c20

@serhiy-storchaka
Copy link
Member

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.

@terryjreedy
Copy link
Member Author

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.

@terryjreedy
Copy link
Member Author

Related bpo-23220 has draft of part of what pushed. I want to do more on the subject.

@serhiy-storchaka
Copy link
Member

Yet one example of test stream that has no buffer - stdprinter used as sys.stderr on early stage of Python startup.

@terryjreedy
Copy link
Member Author

I changed title to 'review' (TextIOBase doc and StringIO as a pure text implementation).

@terryjreedy terryjreedy added the 3.9 only security fixes label Jan 7, 2020
@terryjreedy terryjreedy changed the title Idle: pseudofiles have no buffer attribute. Idle: review 'missing' attributes of pseudofiles Jan 7, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes docs Documentation in the Doc dir topic-IDLE type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

2 participants