summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-02-08 09:47:29 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-02-08 09:47:29 (GMT)
commit57e41277813163a90129a8c4d5f62f0ca68793b6 (patch)
treea9ccc4714b7582ae22d9e1cbdd36e57c031f7b88 /Lib/idlelib
parentbfd68bf4ac6661bf0fab51178583bee88840a8e6 (diff)
downloadcpython-57e41277813163a90129a8c4d5f62f0ca68793b6.zip
cpython-57e41277813163a90129a8c4d5f62f0ca68793b6.tar.gz
cpython-57e41277813163a90129a8c4d5f62f0ca68793b6.tar.bz2
Issue #20167: Suppress 3.4 specific 'Exception ignored' messages.
Original patch by Tal Einat.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/MultiCall.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
index 64729ea..477db2e 100644
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -57,6 +57,13 @@ _modifier_names = dict([(name, number)
for number in range(len(_modifiers))
for name in _modifiers[number]])
+# In 3.4, if no shell window is ever open, the underlying Tk widget is
+# destroyed before .__del__ methods here are called. The following
+# is used to selectively ignore shutdown exceptions to avoid
+# 'Exception ignored' messages. See http://bugs.python.org/issue20167
+APPLICATION_GONE = '''\
+can't invoke "bind" command: application has been destroyed'''
+
# A binder is a class which binds functions to one type of event. It has two
# methods: bind and unbind, which get a function and a parsed sequence, as
# returned by _parse_sequence(). There are two types of binders:
@@ -98,7 +105,12 @@ class _SimpleBinder:
def __del__(self):
if self.handlerid:
- self.widget.unbind(self.widgetinst, self.sequence, self.handlerid)
+ try:
+ self.widget.unbind(self.widgetinst, self.sequence,
+ self.handlerid)
+ except tkinter.TclError as e:
+ if e.args[0] == APPLICATION_GONE:
+ pass
# An int in range(1 << len(_modifiers)) represents a combination of modifiers
# (if the least significent bit is on, _modifiers[0] is on, and so on).
@@ -227,7 +239,11 @@ class _ComplexBinder:
def __del__(self):
for seq, id in self.handlerids:
- self.widget.unbind(self.widgetinst, seq, id)
+ try:
+ self.widget.unbind(self.widgetinst, seq, id)
+ except tkinter.TclError as e:
+ if e.args[0] == APPLICATION_GONE:
+ break
# define the list of event types to be handled by MultiEvent. the order is
# compatible with the definition of event type constants.
@@ -390,8 +406,11 @@ def MultiCallCreator(widget):
func, triplets = self.__eventinfo[virtual]
if func:
for triplet in triplets:
- self.__binders[triplet[1]].unbind(triplet, func)
-
+ try:
+ self.__binders[triplet[1]].unbind(triplet, func)
+ except tkinter.TclError as e:
+ if e.args[0] == APPLICATION_GONE:
+ break
_multicall_dict[widget] = MultiCall
return MultiCall