Skip to content

Commit 347e7ec

Browse files
committed
Fix: allow int for Scanner delimiter (b''.find(int(delimiter) works fine, and this makes related tests pass).
1 parent 1fa06cb commit 347e7ec

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

openlcb/scanner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ class Scanner:
1717
_onHasNext on every push). Mimic Java behavior where
1818
"\\Z" can be added as the delimiter for EOF.
1919
"""
20-
EOF = bytes([0x05]) # flag value *not* used for find arg
20+
EOF = 0x05 # flag value (*skips find*)
2121
# ESCAPED_EOF = ESCAPED_EOF_S.encode("utf-8")
2222
# EOF = 0x05 # type: int
2323
# EOF = -1
2424

2525
def __init__(self, delimiter: Union[bytes, bytearray, int] = EOF):
26-
if isinstance(delimiter, int):
27-
delimiter = bytes([delimiter])
28-
self._delimiter = delimiter # type: Union[bytes, bytearray]
26+
# ^ NOTE: b''.find(int(delimiter)) works fine
27+
self._delimiter = delimiter # type: Union[bytes, bytearray, int]
2928
self._buffer = bytearray()
3029

3130
def push(self, data: Union[bytearray, bytes, int]):

0 commit comments

Comments
 (0)