Skip to content

Keep debug() working when an object's repr raises - #182

Open
akzarma wants to merge 1 commit into
samuelcolvin:mainfrom
akzarma:fix/devtools-debug-repr-fallback
Open

akzarma wants to merge 1 commit into
samuelcolvin:mainfrom
akzarma:fix/devtools-debug-repr-fallback

Conversation

@akzarma

@akzarma akzarma commented Nov 21, 2026 •

Copy link
Copy Markdown

When pretty printing raises, debug() falls back to calling repr() on the value. If that also raises (for example, a repr that accesses a closed resource), the debugging call currently raises instead of returning the original object.

Keep the normal repr fallback. If it raises, print <unrepresentable value> with the type and the original pretty-printing diagnostic, then return the original object as usual.

Validation: The focused regression failed before and passed after the change. The full pytest suite passed (154 passed, 1 skipped). Ruff lint and formatting checks and strict basedpyright passed.

Prepared and tested with AI assistance.


Summary by cubic

debug() no longer raises when both pretty printing and repr() fail. It prints <unrepresentable value> with the object's type and the pretty-printing diagnostic, then returns the original object as before. Added a regression test for a value whose repr raises.

Written for commit c88100f. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

View guided diff | Re-trigger cubic

@akzarma
akzarma force-pushed the fix/devtools-debug-repr-fallback branch from 94e2c83 to c88100f Compare November 21, 2026 12:30

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant