Skip to content

Commit f97b539

Browse files
committed
extmod/uasyncio: Add StreamReader/StreamWriter as aliases of Stream cls.
To be compatible with CPython. Fixes issue adafruit#5847.
1 parent aca19c2 commit f97b539

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

docs/library/uasyncio.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ TCP stream connections
177177
.. class:: Stream()
178178

179179
This represents a TCP stream connection. To minimise code this class implements
180-
both a reader and a writer.
180+
both a reader and a writer, and both ``StreamReader`` and ``StreamWriter`` alias to
181+
this class.
181182

182183
.. method:: Stream.get_extra_info(v)
183184

extmod/uasyncio/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"Lock": "lock",
1313
"open_connection": "stream",
1414
"start_server": "stream",
15+
"StreamReader": "stream",
16+
"StreamWriter": "stream",
1517
}
1618

1719
# Lazy loader, effectively does:

extmod/uasyncio/stream.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ async def drain(self):
5353
self.out_buf = b""
5454

5555

56+
# Stream can be used for both reading and writing to save code size
57+
StreamReader = Stream
58+
StreamWriter = Stream
59+
60+
5661
# Create a TCP stream connection to a remote host
5762
async def open_connection(host, port):
5863
from uerrno import EINPROGRESS

0 commit comments

Comments
 (0)