Skip to content

SocketStream.receive sometimes returns bytearray objects on Windows #776

@jonathanslenders

Description

@jonathanslenders

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#L1075
incorrectly assumes that it will only get bytes objects as an argument. Unfortunately, on Windows, that's not the case. For the ProactorEventLoop, we'll get bytearray objects here.

See:

I think the quickest fix for anyio is to accept bytearray as well, and convert it into bytes, 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions