From ee27e07bf394cab81bcebd9a09a6404b53db1220 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 22 Oct 2026 17:44:34 +0000 Subject: [PATCH 1/3] Ignore `EPERM` when setting low latency --- serialx/platforms/serial_linux.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serialx/platforms/serial_linux.py b/serialx/platforms/serial_linux.py index 8f08d09..b8ac83f 100644 --- a/serialx/platforms/serial_linux.py +++ b/serialx/platforms/serial_linux.py @@ -304,6 +304,8 @@ def _after_configure_port(self) -> None: except OSError as exc: if exc.errno in (errno.ENOTTY, errno.EOPNOTSUPP): LOGGER.debug("Device does not support setting low latency") + elif exc.errno == errno.EPERM: + LOGGER.debug("User does not have permission to set low latency") else: raise From 7986f83fbd95db369804a9663e6b83260ee90ab7 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 22 Oct 2026 17:53:23 +0000 Subject: [PATCH 2/3] Add a test --- tests/test_serial_linux.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_serial_linux.py b/tests/test_serial_linux.py index 0a053e8..2da45a0 100644 --- a/tests/test_serial_linux.py +++ b/tests/test_serial_linux.py @@ -4,7 +4,7 @@ import pytest -if sys.platform != "linux": +if sys.platform not in ("linux", "darwin"): pytest.skip("Linux-only tests", allow_module_level=True) import asyncio @@ -101,15 +101,23 @@ def test_set_non_posix_baudrate_zero_speed_raises() -> None: assert captured == [] +@pytest.mark.parametrize( + "err", + [ + OSError(errno.EOPNOTSUPP, "Not supported"), + OSError(errno.ENOTTY, "Inappropriate ioctl for device"), + OSError(errno.EPERM, "Operation not permitted"), + ], +) @patch("serialx.platforms.serial_linux.TIOCGSERIAL", TIOCGSERIAL) @patch("serialx.platforms.serial_linux.TIOCSSERIAL", TIOCSSERIAL) -def test_tiocgserial_ioctl_not_supported() -> None: +def test_tiocgserial_ioctl_not_supported(err: OSError) -> None: """Test that TIOCGSERIAL ioctl not supported is handled gracefully.""" ioctl_orig = fcntl.ioctl def ioctl(fd: int, request: int, arg: Any = 0, mutate_flag: bool = True) -> Any: if request in (TIOCGSERIAL, TIOCSSERIAL): - raise OSError(errno.EOPNOTSUPP, "Not supported") + raise err return ioctl_orig(fd, request, arg, mutate_flag) From 0cfd7a562c6857bf9dbfbfa55319319ecae6426e Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:24:48 +0000 Subject: [PATCH 3/3] Swap back to Linux-only tests --- tests/test_serial_linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_serial_linux.py b/tests/test_serial_linux.py index 2da45a0..fd7428c 100644 --- a/tests/test_serial_linux.py +++ b/tests/test_serial_linux.py @@ -4,7 +4,7 @@ import pytest -if sys.platform not in ("linux", "darwin"): +if sys.platform != "linux": pytest.skip("Linux-only tests", allow_module_level=True) import asyncio