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 on OS X with Cocoa Tk 8.5 can hang waiting on input / raw_input
Type: behavior Stage: resolved
Components: IDLE, macOS Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: amcnerney13, ned.deily, python-dev, ronaldoussoren
Priority: critical Keywords: patch

Created on 2011-02-01 11:02 by ned.deily, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-11088.patch ronaldoussoren, 2011-03-15 21:27 review
issue11088-py27.txt ronaldoussoren, 2011-03-16 19:24
Messages (14)
msg127691 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-02-01 11:02
As reported by Alex McNerney in Issue11075 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 Issue10940.  Investigating further for impact on 3.2.
msg131002 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-15 17:49
This does seem to be gone in 3.2 with a up-to-date Tk 8.5 from ActiveState.
msg131009 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-03-15 17:57
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.
msg131010 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-15 18:04
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.
msg131013 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-03-15 18:14
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.
msg131035 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-15 20:31
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.
msg131037 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-15 20:51
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.
msg131040 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-15 21:27
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.
msg131158 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-16 19:24
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.
msg131232 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-03-17 07:17
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.
msg136153 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-17 12:49
New changeset 1c6823317a06 by Ronald Oussoren in branch '3.2':
Fixes #11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
http://hg.python.org/cpython/rev/1c6823317a06
msg136155 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-17 12:52
New changeset 85aa02bc674c by Ronald Oussoren in branch 'default':
Fixes #11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
http://hg.python.org/cpython/rev/85aa02bc674c
msg136156 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-17 13:13
New changeset 578020fe2875 by Ronald Oussoren in branch '2.7':
(backport) Fixes #11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
http://hg.python.org/cpython/rev/578020fe2875
msg136157 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-05-17 13:14
I don't really like this patch, but like crashes that cause data loss even less...
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55297
2011-05-17 13:14:46ronaldoussorensetstatus: open -> closed
resolution: fixed
messages: + msg136157

stage: resolved
2011-05-17 13:13:56python-devsetmessages: + msg136156
2011-05-17 12:52:48python-devsetmessages: + msg136155
2011-05-17 12:49:51python-devsetnosy: + python-dev
messages: + msg136153
2011-04-16 06:26:15ned.deilylinkissue11853 superseder
2011-03-17 07:17:52ned.deilysetnosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131232
2011-03-16 19:24:33ronaldoussorensetfiles: + issue11088-py27.txt
nosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131158
2011-03-15 21:27:19ronaldoussorensetfiles: + issue-11088.patch
nosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131040
2011-03-15 21:25:30ronaldoussorensetfiles: - issue-11088.patch
nosy: ronaldoussoren, ned.deily, amcnerney13
2011-03-15 20:51:17ronaldoussorensetfiles: + issue-11088.patch

messages: + msg131037
keywords: + patch
nosy: ronaldoussoren, ned.deily, amcnerney13
2011-03-15 20:31:23ronaldoussorensetnosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131035
2011-03-15 18:14:05ned.deilysetnosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131013
2011-03-15 18:04:16ronaldoussorensetnosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131010
2011-03-15 17:57:47ned.deilysetnosy: ronaldoussoren, ned.deily, amcnerney13
messages: + msg131009
2011-03-15 17:49:43ronaldoussorensetnosy: + ronaldoussoren
messages: + msg131002
2011-02-01 11:02:47ned.deilycreate