Skip to content

Preserve dict insertion order in safeformat output (fixes #13503) #13609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

wak327
Copy link

@wak327 wak327 commented Jul 20, 2025

This PR ensures that dictionaries in assertion output retain their insertion order, instead of displaying keys in alphabetical order. This matches Python 3.7+ dict behavior and improves debugging clarity for users.

  • Updates safeformat to use sort_dicts=False with pprint.pformat.
  • Adds a test to verify that dictionary keys are shown in insertion order in output.

Closes #13503.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 20, 2025
Copy link
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.

as mentioned there already is work on this - in a different pr that actually changes the correct code at the correct place

you dont even try to fix the actual issue

@The-Compiler
Copy link
Member

Duplicate of #13587

@The-Compiler The-Compiler marked this as a duplicate of #13587 Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure output order of dictionary keys is alphabetical instead of insertion order
3 participants