Repository navigation
gh-141540: use %r instead of %s in error messages - #141541
alexwlchan wants to merge 1 commit into
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 |
|
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 |
1 similar comment
|
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.
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.
|
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 |
|
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 |
|
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. 😴