Skip to content

Preserve exception notes when encoding log values - #81

Open
SAY-5 wants to merge 1 commit into
nhairs:mainfrom
SAY-5:say5/preserve-exception-notes-20260928
Open

SAY-5 wants to merge 1 commit into
nhairs:mainfrom
SAY-5:say5/preserve-exception-notes-20260928

Conversation

@SAY-5

@SAY-5 SAY-5 commented Sep 29, 2026

Copy link
Copy Markdown

Exceptions passed as dictionary values currently lose their PEP 678 notes, even though the exc_info path preserves them. This appends an exception’s own notes to the existing class/message string in order, preserving empty and multiline notes and leaving note-free output unchanged.

Exception groups keep their existing nonrecursive summary and gain their own notes. Child exceptions and their notes are still rendered through exc_info; this change does not add recursive group formatting. Related to #67.

The regression covers dictionary, nested dictionary, and list values through every available formatter, string subclasses, empty/custom exception messages, and group-own notes. On Python 3.13.0, the new tests fail against the unchanged implementation (12 failures, 6 passing controls) and pass with the fix (18 passed); the full available suite passes (171 tests, stdlib JSON and orjson). Black passes. Pylint and mypy were run and report only the same missing msgspec dependency diagnostics as the unchanged baseline. The msgspec backend and other Python/platform versions have not been tested locally.

This PR was prepared with AI assistance (OpenAI Codex).

@nhairs

nhairs commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks for this @SAY-5.

Before we go much further I want to investigate changes to the __str__ / __repr__ of exceptions as it looks like it's changed in the last few python versions.

Meaning that some of these changes might be redundant, and some of the existing code might also be redundant.

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.

2 participants