Skip to content

IDLE - shell restart or closing during readline does not exit nested event loop #58462

Closed

Description

@serwy
mannequin
BPO 14254
Nosy @terryjreedy, @ned-deily, @serwy
Files
  • reading_reset.patch
  • reading_reset_rev1.patch
  • stop_readline.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 = 'https://github.com/serwy'
    closed_at = <Date 2013-04-03.05:45:33.718>
    created_at = <Date 2012-03-11.17:51:12.566>
    labels = ['expert-IDLE', 'type-bug']
    title = 'IDLE - shell restart or closing during readline does not exit nested event loop'
    updated_at = <Date 2013-04-03.05:45:33.717>
    user = 'https://github.com/serwy'

    bugs.python.org fields:

    activity = <Date 2013-04-03.05:45:33.717>
    actor = 'roger.serwy'
    assignee = 'roger.serwy'
    closed = True
    closed_date = <Date 2013-04-03.05:45:33.718>
    closer = 'roger.serwy'
    components = ['IDLE']
    creation = <Date 2012-03-11.17:51:12.566>
    creator = 'roger.serwy'
    dependencies = []
    files = ['24784', '29642', '29643']
    hgrepos = []
    issue_num = 14254
    keywords = ['patch']
    message_count = 12.0
    messages = ['155398', '185690', '185691', '185692', '185695', '185705', '185712', '185714', '185716', '185884', '185885', '185890']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'ned.deily', 'roger.serwy', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue14254'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    Activity

    1. serwy commented on Mar 11, 2012

      serwymannequin
      MannequinAuthor

      In PyShell.py, the "readline" method enters a nested event loop for handling input.

      If the shell is restarted, the nested event loop remains until after the first press of "enter" causes the "enter_callback" to quit the nested event loop. The effect is that the first line of input to the prompt is ignored by the new shell.

      Attached is a patch against 3.3 to fix the problem.

    2. added
      type-bug
      on Mar 11, 2012
    3. serwy commented on Mar 31, 2013

      serwymannequin
      MannequinAuthor

      Closing the shell window while in the nested event loop for readline fails to exit the nested event loop. I updated the title to reflect the broader problem with readline's handling of the nested event loop.

      The rev1 patch causes the nested event loop to exit when restarting or closing the shell.

    4. changed the title [-]IDLE - shell restart during readline does not reset readline[/-] [+]IDLE - shell restart or closing during readline does not exit nested event loop[/+] on Mar 31, 2013
    5. self-assigned this
      on Mar 31, 2013
    6. ned-deily commented on Mar 31, 2013

      @ned-deily
      Member

      With the rev1 patch (on OS X), the cursor seems to end up on the wrong line after the restart:

      >> import sys
      >> sys.stdin.readline()

      >> ================================ RESTART ================================

      >>> 
      *Cursor left here at (*), i.e. the left margin of the next line, not on the same line as the ">>> " prompt.
    7. ned-deily commented on Mar 31, 2013

      @ned-deily
      Member

      However, the patch *does* fix the original problem that the first input after restart is skipped.

    8. serwy commented on Mar 31, 2013

      serwymannequin
      MannequinAuthor

      Ned, I can confirm the behavior you are seeing. I am trying to trace down why this spurious '\n' gets inserted.

    9. serwy commented on Apr 1, 2013

      serwymannequin
      MannequinAuthor

      I reworked the patch to fix the cursor problem. The new code, hopefully, is simpler to understand and harder to break. Essentially, all code paths that terminate the subprocess must also call stop_readline which exits that nested event loop if needed.

    10. ned-deily commented on Apr 1, 2013

      @ned-deily
      Member

      With the stop_readline patch, I'm seeing this exception upon shell restart when trying the same test as above:

      $ ./python -m idlelib
      Exception in Tkinter callback
      Traceback (most recent call last):
        File "Lib/tkinter/__init__.py", line 1475, in __call__
          return self.func(*args)
        File "Lib/idlelib/PyShell.py", line 1225, in restart_shell
          self.interp.restart_subprocess(with_cwd=True)
        File "Lib/idlelib/PyShell.py", line 457, in restart_subprocess
          console.stop_readline()
      AttributeError: 'PyShell' object has no attribute 'stop_readline'
    11. serwy commented on Apr 1, 2013

      serwymannequin
      MannequinAuthor

      I just re-applied the patch to a clean 2.7 and 3.4 branch and didn't see that exception raised. Are you sure that the patch applied cleanly?

    12. ned-deily commented on Apr 1, 2013

      @ned-deily
      Member

      Ah, sorry, I mis-edited the patch when check_whitespace.py complained about a whitespace problem. The test does now work correctly, thanks.

    13. serwy commented on Apr 3, 2013

      serwymannequin
      MannequinAuthor

      Ned, I was reading the dev guide more closely about the meaning of the "commit review" stage. Would it be ok to place this issue into that stage with your test result?

    14. ned-deily commented on Apr 3, 2013

      @ned-deily
      Member

      Sure, or just go ahead and commit it. LGTM.

    15. python-dev commented on Apr 3, 2013

      python-devmannequin
      Mannequin

      New changeset 097554712637 by Roger Serwy in branch '2.7':
      bpo-14254: IDLE now handles readline correctly across shell restarts.
      http://hg.python.org/cpython/rev/097554712637

      New changeset 0be85a7fc839 by Roger Serwy in branch '3.3':
      bpo-14254: IDLE now handles readline correctly across shell restarts.
      http://hg.python.org/cpython/rev/0be85a7fc839

      New changeset 4b4f142befea by Roger Serwy in branch 'default':
      bpo-14254: merge with 3.3.
      http://hg.python.org/cpython/rev/4b4f142befea

    16. 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

    Labels

    topic-IDLEtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions