Skip to content

IDLE - readline, isatty, and input broken #59524

Closed

Description

@serwy
mannequin
BPO 15319
Nosy @loewis, @terryjreedy, @ned-deily, @serwy, @serhiy-storchaka
Files
  • stdin_fix.patch
  • idle_stdin_no_rpcfile.patch
  • idle_stdstreams.patch
  • 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 = None
    closed_at = <Date 2012-07-11.06:32:52.768>
    created_at = <Date 2012-07-10.19:28:47.669>
    labels = ['expert-IDLE', 'type-bug']
    title = 'IDLE - readline, isatty, and input broken'
    updated_at = <Date 2012-07-11.09:00:21.223>
    user = 'https://github.com/serwy'

    bugs.python.org fields:

    activity = <Date 2012-07-11.09:00:21.223>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-07-11.06:32:52.768>
    closer = 'loewis'
    components = ['IDLE']
    creation = <Date 2012-07-10.19:28:47.669>
    creator = 'roger.serwy'
    dependencies = []
    files = ['26344', '26346', '26352']
    hgrepos = []
    issue_num = 15319
    keywords = ['patch']
    message_count = 14.0
    messages = ['165198', '165202', '165204', '165214', '165217', '165218', '165222', '165225', '165226', '165227', '165229', '165236', '165237', '165238']
    nosy_count = 7.0
    nosy_names = ['loewis', 'terry.reedy', 'ned.deily', 'roger.serwy', 'python-dev', 'Ramchandra Apte', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue15319'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    Activity

    1. serwy commented on Jul 10, 2012

      serwymannequin
      MannequinAuthor

      Per Martin's request in msg165197, this issue has been separated from bpo-13532.

      The newly introduced _RPCFile object in run.py (422242dbce30) inherits from io.TextIOBase which has "readline" as one of its methods. As a result, IDLE's internal call readline are not handled properly.

      The stdin_fix.patch provides a fix for readline and isatty.

    2. serhiy-storchaka commented on Jul 10, 2012

      @serhiy-storchaka
      Member

      There is a simpler solution of this issue.

    3. serwy commented on Jul 10, 2012

      serwymannequin
      MannequinAuthor

      I like Serhiy's patch. It works for me.

    4. terryjreedy commented on Jul 11, 2012

      @terryjreedy
      Member

      I agree that the _RPCFile wrapping of the stdin proxy should be undone unless and until there is a positive reason for it -- it solves a problem -- and it is better tested. But reversion does not solve pre-existing problems. As noted by Roger, sys.stdin writes, which it should not do. Worse, when directly used, it does not read, which it should do.

      >>> sys.stdin
      <idlelib.rpc.RPCProxy object at 0x0000000003282470>
      >>> dir(sys.stdin)
      ['_RPCProxy__attributes', '_RPCProxy__getattributes', '_RPCProxy__getmethods', '_RPCProxy__methods', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'encoding', 'oid', 'sockio']
      >>> sys.stdin.write('abc')
      abc
      >>> sys.stdin.read()
      Traceback (most recent call last):
        File "<pyshell#4>", line 1, in <module>
          sys.stdin.read()
      AttributeError: read

      versus, in command interpreter (Win7,3.3.0b0)

      >>> sys.stdin.read()
      abcdefg
      ^Z
      'abcdefg\n'
      >>> sys.stdin.write('abc')
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      io.UnsupportedOperation: not writable

      Same difference for readlines and writelines. I wonder how input works if it does not call sys.stdin.read()

      I found this in rpc.py:
      # XXX KBK 09Sep03 We need a proper unit test for this module.
      # Previously existing test code was removed at Rev 1.27 (r34098).

    5. serwy commented on Jul 11, 2012

      serwymannequin
      MannequinAuthor

      Including bpo-15318 where stdin is writable. The proper solution to that issue and this one are likely the same.

    6. serwy commented on Jul 11, 2012

      serwymannequin
      MannequinAuthor

      Same difference for readlines and writelines. I wonder how input works if it does not call sys.stdin.read()

      Eventually IDLE makes a call to PyShell's readline.

    7. terryjreedy commented on Jul 11, 2012

      @terryjreedy
      Member

      Ah, sys.stdin.readline() works. So the object being proxied has readline (and write and writelines) but not read and readlines. I presume the proxy is in the user process and the actual stdin/out/err objects are in the idle process, interacting with the screen and keyboard via tkinter. Do you know what and where it is, so that we could look at it?

    8. changed the title [-]IDLE - input() is broken.[/-] [+]IDLE - sys.stdin is broken.[/+] on Jul 11, 2012
    9. serwy commented on Jul 11, 2012

      serwymannequin
      MannequinAuthor

      PyShell.py's PyShell object has the readline method, at line 1080 in the most recent code. It's meant for use with and without a subprocess. (See also bpo-14254)

      The IDLEfork project long ago created the subprocess and the RPC plumbing for the subprocess interaction with the *existing* PyShell(OutputWindow) object as stdin/stdout/stderr. This RPC, found in rpc.py, is used in run.py and PyShell's ModifiedInterpreter. The start_subprocess method connects the stdin/stdout/stderr from the IDLE front-end to the subprocess in run.py. The stdout/stderr objects are the PyShell(OutputWindow) object wrapped by PseudoFile. Stdin is not wrapped, but it should be.

      I know that this issue deals with stdin specifically, but I hope that the additional stdout/stderr information places the problem into a greater context.

    10. loewis commented on Jul 11, 2012

      loewismannequin
      Mannequin

      I think the issue is grossly underspecified. The title of the issue is "sys.stdin is broken" which says nothing about the way in which it is broken. Taking Roger's literal description, and his msg165191, the complaint is that input() no longer works, as doesn't readline and isatty.

      Since this was what Roger opened the issue for, I declare this to be the issue being dealt with here. I agree that Serhiy's patch is a proper resolution of the issue.

      Roger, please refrain from trying to put issues in a broader scope, unless you make an explicit specification what exactly is in scope and what is out of scope. I readily agree that there are many issues with stdin and stdout in IDLE; I don't agree that easily that they all deserve being resolved. I entirely, completely, absolutely disagree that they are related to what you originally submitted as this issue, as I firmly, deeply convinced believe that the fixes to the other issues will be different from the proper fix to this issue. So please, please, please don't mix issues.

    11. changed the title [-]IDLE - sys.stdin is broken.[/-] [+]IDLE - readline, isatty, and input broken[/+] on Jul 11, 2012
    12. python-dev commented on Jul 11, 2012

      python-devmannequin
      Mannequin

      New changeset b90482742ee0 by Martin v. Löwis in branch '3.2':
      Issue bpo-15319: Revert wrapping of sys.stdin. Patch by Serhiy Storchaka.
      http://hg.python.org/cpython/rev/b90482742ee0

    13. python-dev commented on Jul 11, 2012

      python-devmannequin
      Mannequin

      New changeset 42424c1f605c by Martin v. Löwis in branch '2.7':
      Issue bpo-15319: Revert wrapping of sys.stdin. Patch by Serhiy Storchaka.
      http://hg.python.org/cpython/rev/42424c1f605c

    14. serhiy-storchaka commented on Jul 11, 2012

      @serhiy-storchaka
      Member

      title: IDLE - input() is broken. -> IDLE - sys.stdin is broken.

      Well, now, with the modified header, I'm not going to open a separate
      issue. Here is a patch that fixes almost all IDLE sys.std* issues.

    15. changed the title [-]IDLE - readline, isatty, and input broken[/-] [+]IDLE - sys.stdin, sys.stdout, etc are broken[/+] on Jul 11, 2012
    16. loewis commented on Jul 11, 2012

      loewismannequin
      Mannequin

      Serhiy: this issue is closed, so your patch won't be considered.

    17. serhiy-storchaka commented on Jul 11, 2012

      @serhiy-storchaka
      Member

      Sorry, I missed the morning's discussion.

    18. changed the title [-]IDLE - sys.stdin, sys.stdout, etc are broken[/-] [+]IDLE - readline, isatty, and input broken[/+] on Jul 11, 2012
    19. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      topic-IDLEtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions