Skip to content

Commit 5122fd2

Browse files
jabdoa2rob-smallshire
authored andcommitted
Fix assertions (#13)
Fixes assertions to allow for calls to write write zero bytes of data.
1 parent 91c3776 commit 5122fd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

serial_asyncio/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def write(self, data):
118118
return
119119
if n == len(data):
120120
return # Whole request satisfied
121-
assert n > 0
121+
assert n >= 0 < len(data)
122122
data = data[n:]
123123
self._ensure_writer()
124124

@@ -259,7 +259,7 @@ def _write_ready(self):
259259
self._close()
260260
return
261261

262-
assert n > 0
262+
assert n >= 0 < len(data)
263263
data = data[n:]
264264
self._write_buffer.append(data) # Try again later
265265
self._maybe_resume_protocol()

0 commit comments

Comments
 (0)