Skip to content

gh-71682: Make pprint.pformat always order sets#22977

Open
bbonenfant wants to merge 11 commits into
python:mainfrom
bbonenfant:bugfix/pprint-set-ordering
Open

gh-71682: Make pprint.pformat always order sets#22977
bbonenfant wants to merge 11 commits into
python:mainfrom
bbonenfant:bugfix/pprint-set-ordering

Conversation

@bbonenfant

@bbonenfant bbonenfant commented Oct 25, 2020

Copy link
Copy Markdown

This makes the pprint.pformat perform the default ordering on all set and frozenset objects. This was determined to be a bug, since these objects are ordered if they violate the maximum width of the output, but was never fixed.

Reference: https://bugs.python.org/issue27495

https://bugs.python.org/issue27495

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@bbonenfant

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Comment thread Lib/pprint.py Outdated
del context[objid]
return format % ", ".join(components), readable, recursive

if (issubclass(typ, set) and r is set.__repr__) or \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, but this block is almost a complete duplicate of the one above (please fix that).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have merged this section with the above one. Please let me know if this is satisfactory. I originally separated them to follow the layout of the function and separate out new code from old code.

Comment thread Lib/test/test_pprint.py Outdated
Comment thread Misc/NEWS.d/next/Library/2020-10-26-14-20-58.bpo-27495.OWavSt.rst Outdated
@github-actions

github-actions Bot commented Jan 5, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jan 5, 2021
@tyates-indeed

Copy link
Copy Markdown

I would like to see this get merged in. Is there anything I can do to help get this merged?

@MaxwellDupre MaxwellDupre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see test results say:
Ran 35 tests in 0.123s
OK (expected failures=1)
Looks ok to me.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jul 30, 2022
@rhattersley

Copy link
Copy Markdown

Looks like the only merge conflict is both "Ben Bonenfant" and "David Bonner" have been added to the Misc/ACKS file so it should be trivial to resolve. It'd be great if someone with the relevant permissions could get this in, thanks. 👍

@arhadthedev arhadthedev changed the title bpo-27495: Make pprint.pformat always order sets gh-71682: Make pprint.pformat always order sets Feb 21, 2023
@arhadthedev arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label Feb 21, 2023
@arhadthedev

Copy link
Copy Markdown
Member

@freddrake could you merge this PR if feasible, please (as a pprint expert and a core dev)?

@furkanonder furkanonder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@devdanzin

Copy link
Copy Markdown
Member

As a bugfix, can this still land in 3.13?

@bbonenfant

Copy link
Copy Markdown
Author

I appreciate the continued interest in this PR. I'm happy to do whatever is necessary to get this merged, but I'm not sure what else I can do besides wait for a core team member to give it review.

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review stale Stale PR or inactive for long period of time. stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.