summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2011-05-17 12:48:40 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2011-05-17 12:48:40 (GMT)
commit5ee0567bb2af1c81da72990c9b2cd199af2e2ace (patch)
tree961940d384a3369c24d4dc625fcfd3fadc276df1
parent6edd8c1faf64a118d85355159e5363bba69efe87 (diff)
downloadcpython-5ee0567bb2af1c81da72990c9b2cd199af2e2ace.zip
cpython-5ee0567bb2af1c81da72990c9b2cd199af2e2ace.tar.gz
cpython-5ee0567bb2af1c81da72990c9b2cd199af2e2ace.tar.bz2
Fixes #11088: IDLE crashes when using F5 to run a script on OSX with Tk 8.5
Without this patch IDLE will crash reliably on OSX when Tkinter is linked to TkCocoa 8.5.x. To reproduce: * Create a new file (script.py) with the following two lines: x = input('prompt: ') print(x) * Save the script * Run the script using the F5 keyboard shortcut (running from the menu works fine) The patch is a fairly crude hack, but we haven't found a better workaround for this Tk bug yet.
-rw-r--r--Lib/idlelib/ScriptBinding.py19
-rw-r--r--Misc/NEWS3
2 files changed, 21 insertions, 1 deletions
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
index 41e6a59..90972b5 100644
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -27,6 +27,7 @@ from idlelib.EditorWindow import EditorWindow
from idlelib import PyShell, IOBinding
from idlelib.configHandler import idleConf
+from idlelib import macosxSupport
indent_message = """Error: Inconsistent indentation detected!
@@ -52,6 +53,9 @@ class ScriptBinding:
self.flist = self.editwin.flist
self.root = self.editwin.root
+ if macosxSupport.runningAsOSXApp():
+ self.editwin.text_frame.bind('<<run-module-event-2>>', self._run_module_event)
+
def check_module_event(self, event):
filename = self.getfilename()
if not filename:
@@ -116,14 +120,27 @@ class ScriptBinding:
shell.set_warning_stream(saved_stream)
def run_module_event(self, event):
+ if macosxSupport.runningAsOSXApp():
+ # Tk-Cocoa in MacOSX is broken until at least
+ # Tk 8.5.9, and without this rather
+ # crude workaround IDLE would hang when a user
+ # tries to run a module using the keyboard shortcut
+ # (the menu item works fine).
+ self.editwin.text_frame.after(200,
+ lambda: self.editwin.text_frame.event_generate('<<run-module-event-2>>'))
+ return 'break'
+ else:
+ return self._run_module_event(event)
+
+ def _run_module_event(self, event):
"""Run the module after setting up the environment.
First check the syntax. If OK, make sure the shell is active and
then transfer the arguments, set the run environment's working
directory to the directory of the module being executed and also
add that directory to its sys.path if not already included.
-
"""
+
filename = self.getfilename()
if not filename:
return 'break'
diff --git a/Misc/NEWS b/Misc/NEWS
index 7db72e7..c40136c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,9 @@ Core and Builtins
Library
-------
+- Issue #11088: don't crash when using F5 to run a script in IDLE on MacOSX
+ with Tk 8.5.
+
- Issue #9516: Issue #9516: avoid errors in sysconfig when MACOSX_DEPLOYMENT_TARGET
is set in shell.