Skip to content

Deprecate passing bytes to TerminalReporter.write_line - #15202

Open
LuanaPBueno wants to merge 2 commits into
pytest-dev:mainfrom
LuanaPBueno:deprecate-write-line-bytes
Open

LuanaPBueno wants to merge 2 commits into
pytest-dev:mainfrom
LuanaPBueno:deprecate-write-line-bytes

Conversation

@LuanaPBueno

@LuanaPBueno LuanaPBueno commented Oct 18, 2026 •

Copy link
Copy Markdown

This deprecates passing bytes to TerminalReporter.write_line(), following the steps nicoddemus described in pytest-dev/pytest#7323. Bytes are still decoded for now, so nothing breaks until pytest 10. I used Claude to help, and reviewed and tested the changes myself.

Closes #7323

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • Add text like closes #XYZW to the PR description and/or commits.
  • If AI agents were used, they are credited in Co-authored-by commit trailers.
  • Create a new changelog file in the changelog directory.
  • Add yourself to AUTHORS in alphabetical order.

Closes pytest-dev#7323

Co-authored-by: Claude <noreply@anthropic.com>
Comment thread src/_pytest/deprecated.py
)

TERMINAL_WRITE_LINE_BYTES = PytestRemovedIn10Warning(
"Passing bytes to TerminalReporter.write_line() is deprecated, pass a str instead.\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please use unformattedwarnings

there's a structural issue with -W error triggering problems with the gc if a warning is reused again and again

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! Switched to UnformattedWarning! Can you review for me, please?

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate/drop support for accepting bytes in terminal.write_line

2 participants