[Python-checkins] cpython (2.7): (backport) Fixes #11088: IDLE crashes when using F5 to run a script on OSX with
ronald.oussoren
python-checkins at python.org
Tue May 17 15:13:55 CEST 2011
http://hg.python.org/cpython/rev/578020fe2875
changeset: 70177:578020fe2875
branch: 2.7
parent: 70171:932de36903e7
user: Ronald Oussoren <ronaldoussoren at mac.com>
date: Tue May 17 15:13:46 2011 +0200
summary:
(backport) 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 = raw_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.
files:
Lib/idlelib/ScriptBinding.py | 17 +++++++++++++++++
Misc/NEWS | 3 +++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -26,6 +26,7 @@
from idlelib import PyShell
from idlelib.configHandler import idleConf
+from idlelib import macosxSupport
IDENTCHARS = string.ascii_letters + string.digits + "_"
@@ -53,6 +54,9 @@
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:
@@ -166,6 +170,19 @@
interp.runcode(code)
return 'break'
+ 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).
+ _run_module_event = run_module_event
+
+ def run_module_event(self, event):
+ self.editwin.text_frame.after(200,
+ lambda: self.editwin.text_frame.event_generate('<<run-module-event-2>>'))
+ return 'break'
+
def getfilename(self):
"""Get source filename. If not saved, offer to save (or create) file
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -80,6 +80,9 @@
Library
-------
+- Issue #11088: don't crash when using F5 to run a script in IDLE on MacOSX
+ with Tk 8.5.
+
- Issue #10154, #10090: change the normalization of UTF-8 to "UTF-8" instead
of "UTF8" in the locale module as the latter is not supported MacOSX and OpenBSD.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list