Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9070ade

Browse filesBrowse files
committed
MNT: fix rebase
1 parent 1a1f67f commit 9070ade
Copy full SHA for 9070ade

File tree

Expand file treeCollapse file tree

3 files changed

+11
-69
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-69
lines changed

‎lib/matplotlib/backends/backend_qt.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def start_event_loop(self, timeout=0):
402402
timer = QtCore.QTimer.singleShot(int(timeout * 1000),
403403
event_loop.quit)
404404

405-
with _maybe_allow_interrupt(qApp):
405+
with _maybe_allow_interrupt(event_loop):
406406
qt_compat._exec(event_loop)
407407

408408
def stop_event_loop(self, event=None):

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+5-58Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919
import signal
2020
import socket
21+
import contextlib
2122

2223
from packaging.version import parse as parse_version
2324

@@ -228,8 +229,9 @@ def _maybe_allow_interrupt(qapp):
228229
wsock, rsock = socket.socketpair()
229230
wsock.setblocking(False)
230231
old_wakeup_fd = signal.set_wakeup_fd(wsock.fileno())
231-
sn = QtCore.QSocketNotifier(rsock.fileno(),
232-
QtCore.QSocketNotifier.Read)
232+
sn = QtCore.QSocketNotifier(
233+
rsock.fileno(), _enum('QtCore.QSocketNotifier.Type').Read
234+
)
233235

234236
@sn.activated.connect
235237
def on_signal(*args):
@@ -252,59 +254,4 @@ def handle(*args):
252254
signal.set_wakeup_fd(old_wakeup_fd)
253255
signal.signal(signal.SIGINT, old_sigint_handler)
254256
if handler_args is not None:
255-
old_sigint_handler(handler_args)
256-
257-
# class _maybe_allow_interrupt:
258-
#
259-
# def __init__(self, qt_object):
260-
# self.interrupted_qobject = qt_object
261-
# self.old_fd = None
262-
# self.caught_args = None
263-
#
264-
# self.skip = False
265-
# self.old_sigint_handler = signal.getsignal(signal.SIGINT)
266-
# if self.old_sigint_handler in (None, signal.SIG_IGN, signal.SIG_DFL):
267-
# self.skip = True
268-
# return
269-
#
270-
# QAS = QtNetwork.QAbstractSocket
271-
# self.qt_socket = QAS(QAS.TcpSocket, qt_object)
272-
# # Create a socket pair
273-
# self.wsock, self.rsock = socket.socketpair()
274-
# # Let Qt listen on the one end
275-
# self.qt_socket.setSocketDescriptor(self.rsock.fileno())
276-
# self.wsock.setblocking(False)
277-
# self.qt_socket.readyRead.connect(self._readSignal)
278-
#
279-
# def __enter__(self):
280-
# if self.skip:
281-
# return
282-
#
283-
# signal.signal(signal.SIGINT, self._handle)
284-
# # And let Python write on the other end
285-
# self.old_fd = signal.set_wakeup_fd(self.wsock.fileno())
286-
#
287-
# def __exit__(self, type, val, traceback):
288-
# if self.skip:
289-
# return
290-
#
291-
# signal.set_wakeup_fd(self.old_fd)
292-
# signal.signal(signal.SIGINT, self.old_sigint_handler)
293-
#
294-
# self.wsock.close()
295-
# self.rsock.close()
296-
# self.qt_socket.abort()
297-
# if self.caught_args is not None:
298-
# self.old_sigint_handler(*self.caught_args)
299-
#
300-
# def _readSignal(self):
301-
# # Read the written byte to re-arm the socket if a signal different
302-
# # from SIGINT was caught.
303-
# # Since a custom handler was installed for SIGINT, KeyboardInterrupt
304-
# # is not raised here.
305-
# self.qt_socket.readData(1)
306-
#
307-
# def _handle(self, *args):
308-
# self.caught_args = args # save the caught args to call the old
309-
# # SIGINT handler afterwards
310-
# self.interrupted_qobject.quit()
257+
old_sigint_handler(*handler_args)

‎lib/matplotlib/tests/test_backend_qt.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_qt.py
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ def fire_signal():
7676
platform_simulate_ctrl_c()
7777

7878
qt_core.QTimer.singleShot(100, fire_signal)
79-
try:
79+
with pytest.raises(KeyboardInterrupt):
8080
target(**kwargs)
81-
except KeyboardInterrupt as e:
82-
assert True
83-
else:
84-
assert False # KeyboardInterrupt must be raised
8581

8682

8783
@pytest.mark.backend('QtAgg', skip_on_importerror=True)
@@ -107,12 +103,11 @@ def fire_sigint():
107103

108104
qt_core.QTimer.singleShot(50, fire_other_signal)
109105
qt_core.QTimer.singleShot(100, fire_sigint)
110-
try:
106+
107+
with pytest.raises(KeyboardInterrupt):
111108
target(**kwargs)
112-
except KeyboardInterrupt as e:
113-
assert sigcld_caught
114-
else:
115-
assert False # KeyboardInterrupt must be raised
109+
110+
assert sigcld_caught
116111

117112

118113
@pytest.mark.backend('Qt5Agg')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.