Skip to content

Escape surrogate values in tracing output#684

Open
Himanshuagrawal4 wants to merge 1 commit into
pytest-dev:mainfrom
Himanshuagrawal4:PRO/pluggy-safe-tracing-surrogates
Open

Escape surrogate values in tracing output#684
Himanshuagrawal4 wants to merge 1 commit into
pytest-dev:mainfrom
Himanshuagrawal4:PRO/pluggy-safe-tracing-surrogates

Conversation

@Himanshuagrawal4
Copy link
Copy Markdown

Summary

  • Use
    epr() for hook kwarg values in trace output so surrogate characters are escaped safely.
  • Pre-format hook return values before writing tracing output while keeping structural trace labels readable.
  • Add regression tests for surrogate values in hook arguments and return values.

Tests

  • git diff --check
  • PYTHONPATH=src python -m pytest testing\test_tracer.py::test_dictargs_escape_surrogate_values testing\test_pluginmanager.py::test_hook_tracing_escapes_surrogate_values -q (2 passed)
  • PYTHONPATH=src python -m pytest testing\test_tracer.py testing\test_pluginmanager.py -q (49 passed)

Fixes #681.

@Himanshuagrawal4 Himanshuagrawal4 marked this pull request as ready for review June 4, 2026 19:35
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.

Tracing crashes with UnicodeEncodeError on surrogate escapes in hook arguments/results

1 participant