Skip to content

Conversation

@Tpt
Copy link
Contributor

@Tpt Tpt commented Dec 1, 2025

Simplifies the type hint: bytes and bytearray are extending Sequence[int]

Allows to drop INPUT_SEQUENCE_TYPE

Close #5658

/// If it is a `bytearray`, its contents will be copied to an owned `Cow`.
impl<'a, 'py> crate::conversion::FromPyObject<'a, 'py> for Cow<'a, [u8]> {
type Error = CastError<'a, 'py>;
type Error = PyErr;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed because conversion from arbitrary sequences can raise Python exceptions

Simplifies the type hint: bytes and bytearray are Sequence[int]

Allows to drop INPUT_SEQUENCE_TYPE
@Tpt Tpt marked this pull request as ready for review December 2, 2025 09:35
Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this seems like a good simplification to me.

@davidhewitt davidhewitt added this pull request to the merge queue Dec 7, 2025
Merged via the queue into PyO3:main with commit 5e6df2d Dec 7, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make byte sequence input types more consistent

2 participants