summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2024-02-25 15:38:10 +1300
committertoofar <toofar@spalge.com>2024-02-25 15:56:34 +1300
commit145bfe4de0802e7eb21ef902e8e53544e996d3a4 (patch)
tree3d70b63ad55d025156c311ca341542905d65e044
parent6050017809a2980934e626a6da5418b07838478a (diff)
downloadqutebrowser-145bfe4de0802e7eb21ef902e8e53544e996d3a4.tar.gz
qutebrowser-145bfe4de0802e7eb21ef902e8e53544e996d3a4.zip
windows doesn't support SIGHUP
It gives an AttributeError for both signal.SIGHUP and signal.Signals.SIGHUP. The Signals Enum is set up so you can use the strings to key into it though, so that's nice. I was tempted to use a walrus operator here but I think that's python 310 and I don't remember what our minimum supported version is.
-rw-r--r--qutebrowser/misc/crashsignal.py7
-rw-r--r--tests/unit/misc/test_crashsignal.py2
2 files changed, 8 insertions, 1 deletions
diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py
index daffa6341..05e5806df 100644
--- a/qutebrowser/misc/crashsignal.py
+++ b/qutebrowser/misc/crashsignal.py
@@ -326,8 +326,13 @@ class SignalHandler(QObject):
self._handlers = {
signal.SIGINT: self.interrupt,
signal.SIGTERM: self.interrupt,
- signal.SIGHUP: self.reload_config,
}
+ platform_dependant_handlers = {
+ "SIGHUP": self.reload_config,
+ }
+ for sig_str, handler in platform_dependant_handlers.items():
+ if hasattr(signal.Signals, sig_str):
+ self._handlers[signal.Signals[sig_str]] = handler
def activate(self):
"""Set up signal handlers.
diff --git a/tests/unit/misc/test_crashsignal.py b/tests/unit/misc/test_crashsignal.py
index e4570420e..7019118e5 100644
--- a/tests/unit/misc/test_crashsignal.py
+++ b/tests/unit/misc/test_crashsignal.py
@@ -80,12 +80,14 @@ def test_interrupt_repeatedly(signal_handler):
expected(test_signal, None)
+@pytest.mark.posix
def test_reload_config_call_on_hup(signal_handler, read_config_mock):
signal_handler._handlers[signal.SIGHUP](None, None)
read_config_mock.assert_called_once_with("config.py-unittest")
+@pytest.mark.posix
def test_reload_config_displays_errors(signal_handler, read_config_mock, mocker):
read_config_mock.side_effect = configexc.ConfigFileErrors(
"config.py",