Skip to content

Handle broken repr in tracing#666

Open
ShipItAndPray wants to merge 1 commit into
pytest-dev:mainfrom
ShipItAndPray:fix-424-safe-tracing
Open

Handle broken repr in tracing#666
ShipItAndPray wants to merge 1 commit into
pytest-dev:mainfrom
ShipItAndPray:fix-424-safe-tracing

Conversation

@ShipItAndPray
Copy link
Copy Markdown

Summary

  • guard tracing stringification so hook tracing does not break hook execution when traced objects have a broken __repr__/__str__
  • keep the fallback output informative by using the default object repr and the original exception
  • add a regression test covering broken repr values in traced hook kwargs

Testing

  • uv run --python 3.12 pytest testing/test_pluginmanager.py -k broken_repr -q
  • uv run --python 3.12 pytest testing/test_pluginmanager.py -q

Closes #424.

Copy link
Copy Markdown
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

this is in part ad odds with switching to repr in another pr
also as far as i understood there is a general understanding that str/repr should never fail for object that completed their ctor

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.

Avoid erroring from tracing

3 participants