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

Skip to content

Commit 444838e

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #16311: don't override non-Python signal handlers
1 parent 6353165 commit 444838e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,11 @@ def trigger_manager_draw(manager):
10421042
def mainloop():
10431043
old_signal = signal.getsignal(signal.SIGINT)
10441044
# allow SIGINT exceptions to close the plot window.
1045-
signal.signal(signal.SIGINT, signal.SIG_DFL)
1045+
if old_signal:
1046+
signal.signal(signal.SIGINT, signal.SIG_DFL)
10461047
try:
10471048
qApp.exec_()
10481049
finally:
10491050
# reset the SIGINT exception handler
1050-
signal.signal(signal.SIGINT, old_signal)
1051+
if old_signal:
1052+
signal.signal(signal.SIGINT, old_signal)

0 commit comments

Comments
 (0)