Skip to content

Commit

Permalink
[Update] io: writable supports bytearray
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien committed Oct 2, 2024
1 parent 6f2f512 commit 2db9769
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/py/extra/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def asBytes(value: str | bytes) -> bytes:
raise ValueError(f"Expected bytes or str, got: {value}")


def asWritable(value: str | bytes | TPrimitive) -> bytes:
if isinstance(value, bytes):
def asWritable(value: str | bytes | bytearray | TPrimitive) -> bytes:
if isinstance(value, bytes) or isinstance(value, bytearray):
return value
elif isinstance(value, str):
return value.encode(DEFAULT_ENCODING)
Expand Down Expand Up @@ -69,6 +69,7 @@ def feed(self, chunk: bytes, start: int = 0) -> tuple[bytes | None, int]:
return None, len(chunk) - start
else:
self.line = self.buffer[:end]
# FIXME: It may not be .clear()?
self.buffer.clear()
self.offset = 0
return self.line, (end - pos) + self.eolsize
Expand Down

0 comments on commit 2db9769

Please sign in to comment.