Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf7618c

Browse files
committed
Merge pull request #1098 from efiring/suppress_closing_exception
suppress exception upon quitting with qt4agg on osx
2 parents 9aab0be + 9520d9f commit cf7618c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,11 +1599,13 @@ def close_event(self, guiEvent=None):
15991599
try:
16001600
event = CloseEvent(s, self, guiEvent=guiEvent)
16011601
self.callbacks.process(s, event)
1602-
except TypeError:
1602+
except (TypeError, AttributeError):
16031603
pass
16041604
# Suppress the TypeError when the python session is being killed.
16051605
# It may be that a better solution would be a mechanism to
16061606
# disconnect all callbacks upon shutdown.
1607+
# AttributeError occurs on OSX with qt4agg upon exiting
1608+
# with an open window; 'callbacks' attribute no longer exists.
16071609

16081610
def key_press_event(self, key, guiEvent=None):
16091611
"""
@@ -2423,12 +2425,12 @@ def __init__(self, canvas, num):
24232425
self.key_press)
24242426
"""
24252427
The returned id from connecting the default key handler via :meth:`FigureCanvasBase.mpl_connnect`.
2426-
2428+
24272429
To disable default key press handling::
2428-
2430+
24292431
manager, canvas = figure.canvas.manager, figure.canvas
24302432
canvas.mpl_disconnect(manager.key_press_handler_id)
2431-
2433+
24322434
"""
24332435

24342436
def destroy(self):

0 commit comments

Comments
 (0)