Skip to content

gh-141510: Support frozendict in pprint - #144908

Merged
vstinner merged 7 commits into
python:mainfrom
vstinner:frozendict_pprint
Feb 21, 2026
Merged

vstinner merged 7 commits into
python:mainfrom
vstinner:frozendict_pprint

Conversation

@vstinner

@vstinner vstinner commented Feb 17, 2026 •

Copy link
Copy Markdown
Member
@vstinner

Copy link
Copy Markdown
Member Author

@serhiy-storchaka serhiy-storchaka 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.

What about frozendict views?

Comment thread Lib/pprint.py Resolved
@devdanzin

Copy link
Copy Markdown
Member

frozendict views are standard dict views.

@vstinner

Copy link
Copy Markdown
Member Author

I completed the PR. Please review again.

What about frozendict views?

I added multiple tests on keys(), values() and items().

@serhiy-storchaka serhiy-storchaka 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.

LGTM if all new code is covered by tests.

Comment thread Lib/pprint.py
return "{%s}" % ", ".join(components), readable, recursive
rep = "{%s}" % ", ".join(components)
if is_frozendict:
rep = f"{object.__class__.__name__}({rep})"

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.

Is it covered by tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This line is coverted by test_basic_line_wrap() and test_same_as_repr() tests. If I modify the code to raise an exception, both tests fail.

@vstinner
vstinner merged commit 770d354 into python:main Feb 21, 2026
45 checks passed
@vstinner
vstinner deleted the frozendict_pprint branch February 21, 2026 16:08
@vstinner

Copy link
Copy Markdown
Member Author

Merged. Thanks for reviews! Thanks for your contribution @devdanzin!

brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants