SocketStream.receive
sometimes returns bytearray
objects on Windows
#776
Labels
bug
Something isn't working
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
AnyIO version
4.4.0
Python version
3.11
What happened?
StreamProtocol
, here: https://github.com/agronholm/anyio/blob/master/src/anyio/_backends/_asyncio.py#L1075incorrectly assumes that it will only get
bytes
objects as an argument. Unfortunately, on Windows, that's not the case. For theProactorEventLoop
, we'll getbytearray
objects here.See:
asyncio.Protocol.data_received
should also acceptbytearray
alongsidebytes
python/typeshed#12606asyncio.BaseProactorEventLoop
feeds bytearray objects to theProtocol.data_received
callback, contradicting docs python/cpython#123496I think the quickest fix for anyio is to accept
bytearray
as well, and convert it intobytes
, regardless of what typeshed/cpython do.How can we reproduce the bug?
(Sorry, I don't have access to a Windows machine right now to create an example, but please let me know if an example script is needed.)
The text was updated successfully, but these errors were encountered: