Skip to content

Handle empty bytes in echo#3493

Merged
davidism merged 1 commit into
pallets:stablefrom
Iain-S:issue3487-echo-bytes
May 21, 2026
Merged

Handle empty bytes in echo#3493
davidism merged 1 commit into
pallets:stablefrom
Iain-S:issue3487-echo-bytes

Conversation

@Iain-S
Copy link
Copy Markdown

@Iain-S Iain-S commented May 21, 2026

Previously, an empty byte string could cause an exception if nl=True.

This PR narrows the type scope of out, to bytes() | bytearray() | str and handles all cases exhaustively.

We also change from typing.Any, which effectively disables typing for a variable, to object, which is more restrictive. See https://mypy.readthedocs.io/en/latest/dynamic_typing.html#any-vs-object for more.

fixes #3487

@Iain-S Iain-S force-pushed the issue3487-echo-bytes branch from e6d8d88 to bef8573 Compare May 21, 2026 10:28
@Iain-S Iain-S marked this pull request as ready for review May 21, 2026 10:35
@davidism davidism added this to the 8.4.1 milestone May 21, 2026
@davidism davidism changed the title Handle empty byte strings in echo. Handle empty bytes in echo May 21, 2026
@davidism davidism changed the base branch from main to stable May 21, 2026 15:25
@davidism davidism force-pushed the issue3487-echo-bytes branch 2 times, most recently from ab163a8 to e6cea36 Compare May 21, 2026 15:28
@davidism

This comment was marked as resolved.

@davidism davidism force-pushed the issue3487-echo-bytes branch from e6cea36 to e2f90b9 Compare May 21, 2026 22:37
@davidism davidism force-pushed the issue3487-echo-bytes branch from e2f90b9 to 4d3db84 Compare May 21, 2026 22:43
@davidism davidism merged commit a5f5aa6 into pallets:stable May 21, 2026
12 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.

Echoing empty bytes or bytearray raises TypeError

2 participants