diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2013-05-31 01:33:12 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2013-05-31 01:33:12 +0000 |
commit | 20e1faeb47f5b4e786f3e53e98f8545af655597a (patch) | |
tree | bd8b3c9bc1027aac6f780ab033a8aa02bd331e4d | |
parent | a505de3cb27e2b1edaf43698da029a9043027156 (diff) | |
download | pyserial-git-20e1faeb47f5b4e786f3e53e98f8545af655597a.tar.gz |
[Bug pyserial:135] reading from socket with timeout=None causes TypeError
-rw-r--r-- | pyserial/CHANGES.txt | 1 | ||||
-rw-r--r-- | pyserial/serial/urlhandler/protocol_socket.py | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt index dee6da0..1658dea 100644 --- a/pyserial/CHANGES.txt +++ b/pyserial/CHANGES.txt @@ -446,6 +446,7 @@ Bugfixes: - [Bug 3540332] SerialException not returned - [Bug pyserial:145] Error in socket_connection.py +- [Bug pyserial:135] reading from socket with timeout=None causes TypeError Bugfixes (posix): diff --git a/pyserial/serial/urlhandler/protocol_socket.py b/pyserial/serial/urlhandler/protocol_socket.py index ccf7e14..0c96511 100644 --- a/pyserial/serial/urlhandler/protocol_socket.py +++ b/pyserial/serial/urlhandler/protocol_socket.py @@ -135,8 +135,11 @@ class SocketSerial(SerialBase): until the requested number of bytes is read.""" if not self._isOpen: raise portNotOpenError data = bytearray() - timeout = time.time() + self._timeout - while len(data) < size and time.time() < timeout: + if self._timeout is not None: + timeout = time.time() + self._timeout + else: + timeout = None + while len(data) < size and (timeout is None or time.time() < timeout): try: # an implementation with internal buffer would be better # performing... |