-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-141540: use %r instead of %s in error messages #141541
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
base: main
Are you sure you want to change the base?
Conversation
|
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 |
83b3d7a to
26b52f4
Compare
|
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 |
26b52f4 to
7065cae
Compare
|
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 |
serhiy-storchaka
left a comment
There was a problem hiding this 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.
7065cae to
c0d8e7a
Compare
|
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 |
|
Since I only expanded beyond the initial |
c0d8e7a to
5ea6398
Compare
|
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 |
5ea6398 to
83eb9d9
Compare
|
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 |
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 astr, 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. 😴