From a866de47fb85087e7ed52cd122dbdb06ee2443fd Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Fri, 10 Oct 2025 19:45:51 -0400 Subject: [PATCH] udev: correctly re-raise access exception --- lib/hidapi/udev_impl.py | 2 +- lib/logitech_receiver/device.py | 6 +++--- lib/logitech_receiver/receiver.py | 2 +- tests/logitech_receiver/test_device.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/hidapi/udev_impl.py b/lib/hidapi/udev_impl.py index 6b12f51d..8b0c1f03 100644 --- a/lib/hidapi/udev_impl.py +++ b/lib/hidapi/udev_impl.py @@ -323,7 +323,7 @@ def open_path(device_path): if e.errno == errno.EACCES: sleep(0.1) else: - raise + raise e def close(device_handle) -> None: diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index 8d391af8..938ab562 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -87,10 +87,10 @@ def create_device(low_level: LowLevelInterface, device_info, setting_callback=No except OSError as e: logger.exception("open %s", device_info) if e.errno == errno.EACCES: - raise - except Exception: + raise e + except Exception as e: logger.exception("open %s", device_info) - raise + raise e class Device: diff --git a/lib/logitech_receiver/receiver.py b/lib/logitech_receiver/receiver.py index 99ec83a8..90c3aa20 100644 --- a/lib/logitech_receiver/receiver.py +++ b/lib/logitech_receiver/receiver.py @@ -599,6 +599,6 @@ def create_receiver(low_level: LowLevelInterface, device_info, setting_callback= except OSError as e: logger.exception("open %s", device_info) if e.errno == errno.EACCES: - raise + raise e except Exception: logger.exception("open %s", device_info) diff --git a/tests/logitech_receiver/test_device.py b/tests/logitech_receiver/test_device.py index 54fe7d07..0d45d69c 100644 --- a/tests/logitech_receiver/test_device.py +++ b/tests/logitech_receiver/test_device.py @@ -86,7 +86,7 @@ def test_create_device(device_info, responses, expected_success): with pytest.raises(PermissionError): device.create_device(low_level_mock, device_info) elif not expected_success: - with pytest.raises(TypeError): + with pytest.raises(Exception): # noqa: B017 device.create_device(low_level_mock, device_info) else: test_device = device.create_device(low_level_mock, device_info)