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 on OS X with Cocoa Tk 8.5 can hang waiting on input / raw_input #55297

Closed
ned-deily opened this issue Feb 1, 2011 · 14 comments
Closed

IDLE on OS X with Cocoa Tk 8.5 can hang waiting on input / raw_input #55297

ned-deily opened this issue Feb 1, 2011 · 14 comments
Assignees
Labels
OS-mac topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@ned-deily
Copy link
Member

BPO 11088
Nosy @ronaldoussoren, @ned-deily
Files
  • issue-11088.patch
  • issue11088-py27.txt
  • 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/ned-deily'
    closed_at = <Date 2011-05-17.13:14:46.073>
    created_at = <Date 2011-02-01.11:02:47.587>
    labels = ['OS-mac', 'expert-IDLE', 'type-bug']
    title = 'IDLE on OS X with Cocoa Tk 8.5 can hang waiting on input / raw_input'
    updated_at = <Date 2011-05-17.13:14:46.072>
    user = 'https://github.com/ned-deily'

    bugs.python.org fields:

    activity = <Date 2011-05-17.13:14:46.072>
    actor = 'ronaldoussoren'
    assignee = 'ned.deily'
    closed = True
    closed_date = <Date 2011-05-17.13:14:46.073>
    closer = 'ronaldoussoren'
    components = ['IDLE', 'macOS']
    creation = <Date 2011-02-01.11:02:47.587>
    creator = 'ned.deily'
    dependencies = []
    files = ['21227', '21247']
    hgrepos = []
    issue_num = 11088
    keywords = ['patch']
    message_count = 14.0
    messages = ['127691', '131002', '131009', '131010', '131013', '131035', '131037', '131040', '131158', '131232', '136153', '136155', '136156', '136157']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'amcnerney13', 'python-dev']
    pr_nums = []
    priority = 'critical'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11088'
    versions = ['Python 2.7', 'Python 3.2']

    @ned-deily
    Copy link
    Member Author

    As reported by Alex McNerney in bpo-11075 msg127687:

    "... running Python 2.7.1:88286 (maintenance) [built from source] on ActiveState Tcl/Tk 8.5.9 causes the idle to hang when a simple script like:
    "
    x = raw_input("x: ")
    print x
    "
    is run. Is this a bug in Tcl/Tk? Looking in the logs I see several instances of "setCanCycle: is deprecated. Please use setCollectionBehavior instead" Does this have any relevancy?"

    I can reproduce the problem using input with Cocoa Tk 8.5 and Python 3.2rc2 or raw_input with Python 2.7.1+. It does not seem to happen with Carbon Tk 8.4. This may be related to bpo-10940. Investigating further for impact on 3.2.

    @ned-deily ned-deily self-assigned this Feb 1, 2011
    @ned-deily ned-deily added topic-IDLE OS-mac type-bug An unexpected behavior, bug, or error labels Feb 1, 2011
    @ronaldoussoren
    Copy link
    Contributor

    This does seem to be gone in 3.2 with a up-to-date Tk 8.5 from ActiveState.

    @ned-deily
    Copy link
    Member Author

    I can still reproduce it in 3.2 with A/S Tk 8.5. The script needs to be run from a separate editor window, not the PyShell window.

    @ronaldoussoren
    Copy link
    Contributor

    On 15 Mar, 2011, at 13:57, Ned Deily wrote:

    Ned Deily <nad@acm.org> added the comment:

    I can still reproduce it in 3.2 with A/S Tk 8.5. The script needs to be run from a separate editor window, not the PyShell window.

    That's odd. What I did:

    • Create a new file (script.py) with the following two lines:
    x = input('prompt: ')
    print(x)
    • Save the script
    • Run the script using the menu

    All of this using an activestate Tcl/Tk that I downloaded earlier today.

    @ned-deily
    Copy link
    Member Author

    Sorry, forgot one crucial step: you have to use the keyboard accelerator (F5) to run the script, not the mouse and the menu. It seems like a number of the problems out there with Cocoa Tk 8.5 have to do with using the keyboard accelerators.

    @ronaldoussoren
    Copy link
    Contributor

    This isn't strictly a key-bindings problem, other events also cause problems.

    I've patched ScriptBinding.py and repacled run_module_event that causes the original, now renamed, method to be called a little why later. This change doesn't fix the issue but makes it even worse: even the menu no longer works.

        def run_module_event(self, event):
            self.editwin.text_frame.after('idle', self._run_module_event, None)
            return 'break'
    
        def _run_module_event(self, event):
            """Run the module after setting up the environment.

    I'm getting more and more disappointed in the way Tk on OSX is moving forward.

    @ronaldoussoren
    Copy link
    Contributor

    Got it to work by introducing both a delayed call and a generated event, just one of those isn't good enough.

    The attached patch seems to fix the issue for me (patch was created using diff(1), not through mercurial).

    I haven't tested this on anything else than IDLE 3.2 on OSX 10.6 with Tk 8.5.9 from ActiveState.

    If this gets committed I'd at the very least use this workaround only for Tk-Cocoa on OSX, and use the current code path on other platforms. That gives more code, but makes it clear than something special is being done for one specific platform.

    @ronaldoussoren
    Copy link
    Contributor

    Added an updated version of the patch:

    • Only perform the workaround in IDLE.app on OSX
    • A slightly longer timeout is needed to work reliably on my machine

    The latter bullet indicates that this is probably not a reliable fix,
    there is a timeing issue.

    @ronaldoussoren
    Copy link
    Contributor

    The same fix also works with 2.7.

    The attached patch is basically the same patch, but the special casing for OSX is impacts other platforms even less than before.

    @ned-deily
    Copy link
    Member Author

    I don't have any better suggestions at the moment so let's go with it. Perhaps we'll get more insight to the root cause later.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 17, 2011

    New changeset 1c6823317a06 by Ronald Oussoren in branch '3.2':
    Fixes bpo-11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
    http://hg.python.org/cpython/rev/1c6823317a06

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 17, 2011

    New changeset 85aa02bc674c by Ronald Oussoren in branch 'default':
    Fixes bpo-11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
    http://hg.python.org/cpython/rev/85aa02bc674c

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 17, 2011

    New changeset 578020fe2875 by Ronald Oussoren in branch '2.7':
    (backport) Fixes bpo-11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
    http://hg.python.org/cpython/rev/578020fe2875

    @ronaldoussoren
    Copy link
    Contributor

    I don't really like this patch, but like crashes that cause data loss even less...

    @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
    OS-mac topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants