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
bpo-20524: adds better error message for .format()
#28310
Conversation
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@ericvsmith Thanks a lot! I've addressed almost all your comments, except ones that you clearly wanted to have some extra research on your side. Let me know if you need my help! |
P.S. To make @bedevere-bot happy: |
Thanks for making the requested changes! @ericvsmith: please review the changes made to this pull request. |
Thanks! I'll see if I can figure out why it's printing out more than just the format spec. I'm also going to mark this as back-portable to 3.10 and 3.9, since changing exception text is okay in a dot release. |
Here's what I don't understand:
Why does the .format() error message say For reference, this is what it looks like in 3.8 (the newest version I have around, but I don't think it makes a difference):
|
In the meantime I will add more tests for |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@ericvsmith Thanks! I've checked all other usages of To make bot happy: I have made the requested changes; please review again. |
Thanks for making the requested changes! @ericvsmith: please review the changes made to this pull request. |
with self.assertRaisesRegex(ValueError, str_err): | ||
"{a:%%k}".format(a='a') | ||
|
||
def test_unicode_in_error_message(self): |
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.
I hadn't noticed this test before. It's great, especially because of the work in using "kind" to compute the actual error message.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I'm going to ask on python-dev and see how people feel about this. |
I'm just waiting on the backport decision to hear if anyone comments on https://mail.python.org/archives/list/python-dev@python.org/message/G6H3M7USSQ2YCFMATMU24J5BJMDJPDVW/ |
The feedback on python-dev is to not backport this. Which is a bummer, but it's the right decision. [Edit: there already is a blurb. Nevermind.] |
@ericvsmith No worries!
You mean something like this? https://github.com/sobolevn/cpython/blob/4a11a03e8922af636c3ff0b3d6d7d6e255304c2b/Misc/NEWS.d/next/Library/2021-09-13-14-59-01.[bpo-20524](https://bugs.python.org/issue20524).PMQ1Fh.rst If yes, it is already included. If not, then I need more help - I am not quite familiar with the process - where should I put it? |
@sobolevn: After I wrote that message, I realized you already had a well written blurb that I skipped over. Thanks for all of your work on this issue. I think it's a great improvement. I just looked at the issue: 7.5 years in the making. Time flies! |
Thanks a lot for your help, @ericvsmith! It was a pleasure P.S. I have some other unreviewed PRs in case you are interested https://github.com/python/cpython/pulls/sobolevn?q=is:open |
This is most likely can be considered as WIP, because I'm still not very familiar with C-API.🙂
Would be happy to learn / address review comments though
https://bugs.python.org/issue20524
https://bugs.python.org/issue20524