Skip to content

Conversation

@alexwlchan
Copy link

@alexwlchan alexwlchan commented Nov 14, 2025

I fixed the original example, then looked for other examples of '%s' and "%s" in error messages that might want to be replaced with %r. This isn't all of them, but it was all the cases where I felt confident I understood the original code, the printed value was a str, and this seemed like a sensible suggestion.

I had issues running the tests locally and it's late here, so I'm going to open this PR now and review any CI failures in the morning. 😴

@bedevere-app
Copy link

bedevere-app bot commented Nov 14, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Nov 14, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Nov 14, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Some error messages match corresponding error messages in the C code which do not use repr.

Some cases are not so simple. For example the repr of the path on Windows is less readable, and paths on Windows cannot contain newlines, quotes or other control characters. On other hand, if the string which is supposed to represent a path contain weird characters, the repr is more helpful. We use repr in some cases (especially if the path can be bytes) and str in other cases (especially if the path can be Path). Each case should be considered carefully.

@bedevere-app
Copy link

bedevere-app bot commented Nov 15, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@alexwlchan
Copy link
Author

Since I only expanded beyond the initial _strptime.py cases based on a suggestion on the original issue, and I don't care to go through these cases in more detail, I've reduced the scope to just that file. I've also converted all the string formatting in that file to f-strings for consistency.

@bedevere-app
Copy link

bedevere-app bot commented Nov 15, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Nov 15, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

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