From 1473494b136e276f59d18dfff12e344d1f0f44c2 Mon Sep 17 00:00:00 2001 From: Ben Gardiner Date: Thu, 5 Feb 2026 09:13:50 -0500 Subject: [PATCH] interfaces/cantact: Handle None timeout by setting to 0 There are definitely cases of client code that end up passing timeout=None to _recv_internal(). Several other interfaces/*.py are prepared for this e.g. canalystii usb2can canlib_vcinpl2 gs_usb.py For cantact I think the right thing to do is set default timeout to 0 if None is provided. --- can/interfaces/cantact.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/can/interfaces/cantact.py b/can/interfaces/cantact.py index ee01fbf94..97c0c5ea4 100644 --- a/can/interfaces/cantact.py +++ b/can/interfaces/cantact.py @@ -125,9 +125,7 @@ def __init__( def _recv_internal(self, timeout: float | None) -> tuple[Message | None, bool]: if timeout is None: - raise TypeError( - f"{self.__class__.__name__} expects a numeric `timeout` value." - ) + timeout = 0 with error_check("Cannot receive message"): frame = self.interface.recv(int(timeout * 1000))