Skip to content

Add bytearray.__bytes__ to support typing.SupportsBytes #146042

@ktbarrett

Description

@ktbarrett

Bug report

Bug description:

from typing import SupportsBytes

a = bytearray()
assert isinstance(a, SupportsBytes)  # Fails
bytes(a)  # No failure

bytes.__bytes__ was added in 3.11 so that bytes could match SupportsBytes, so I would think this should work as well.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions