-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-40679: use a function's qualname in error messages #20236
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
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.
Here are a couple comments. Thanks for the PR!
Misc/NEWS.d/next/Core and Builtins/2020-05-19-19-39-49.bpo-40679.SVzz9p.rst
Outdated
Show resolved
Hide resolved
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 |
@@ -4180,7 +4181,7 @@ _PyEval_EvalCode(PyThreadState *tstate, | |||
if (keyword == NULL || !PyUnicode_Check(keyword)) { | |||
_PyErr_Format(tstate, PyExc_TypeError, | |||
"%U() keywords must be strings", | |||
co->co_name); | |||
qualname); |
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.
Are there any suggestions for how to test this from Python? I couldn't figure out how without getting a SyntaxError
.
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.
Using the ** should do the trick.
For example:
>>> func = lambda *args, **kwargs: None
>>> kwargs = {None: None}
>>> func(kwargs)
>>> func(*kwargs)
>>> func(**kwargs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: <lambda>() keywords must be strings
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.
Unfortunately it looks like this behavior changed a bit in the newest releases so that that code isn't actually reached:
PS > py -3.7 -c "f = lambda x: None; f(**{1:1})"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: <lambda>() keywords must be strings
PS > py -3.8 -c "f = lambda x: None; f(**{1:1})"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: <lambda>() keywords must be strings
PS > py -3.9 -c "f = lambda x: None; f(**{1:1})"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: keywords must be strings
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.
Oh I see... Probably related to 0567786 .
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 think the earlier version where you're using traditional TestCase classes is a bit better because it's more idiomatic. I'm not sure why that large doctest is being used like that.
Also, since assertRaisesRegex()
is annoying to use when you're just trying to test equality, you could define a context manager helper method on your test class as your own replacement. It could look something like this:
with self.assertRaises(TypeError) as cm:
yield
exc = cm.exception
self.assertEqual(str(exc), '<message>')
That would eliminate some boilerplate.
@cjerdonek I switched it back to a standard unittest.TestCase and refactored as you suggested. |
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.
Good work! A few nits, and I think this is good to go. 👍
Misc/NEWS.d/next/Core and Builtins/2020-05-19-19-39-49.bpo-40679.SVzz9p.rst
Outdated
Show resolved
Hide resolved
One of the tests (test_ttk_guionly) on Ubuntu is hanging on this line:
but I think that is unrelated. I think this might be a common intermittent issue. |
Another thing to do to retrigger CI is to do “git commit —amend” (with no
changes) followed by “git push —force-with-lease”.
…On Thu, May 21, 2020 at 1:00 PM Dennis Sweeney ***@***.***> wrote:
Reopened #20236 <#20236>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20236 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACW33R5M4JFGH6RHXACWITRSWB6JANCNFSM4NFJJGUA>
.
|
Thanks. Can you file an issue if there isn’t already one?
…On Thu, May 21, 2020 at 11:44 AM Dennis Sweeney ***@***.***> wrote:
One of the tests (test_ttk_guionly) on Ubuntu is hanging on this line:
https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/tkinter/test/test_ttk/test_extensions.py#L190
but I think that is unrelated. I think this might be a common intermittent
issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20236 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACW33UMATD2MNKDZ54LFRDRSVY75ANCNFSM4NFJJGUA>
.
|
Thanks -- good to know. I opened https://bugs.python.org/issue40722. |
Thanks again for your good work on this, @sweeneyde. |
…H-20236) Patch by Dennis Sweeney.
Related tickets/PRs: * python/cpython#20236 * https://twistedmatrix.com/trac/ticket/10273 git-svn-id: file:///srv/repos/svn-community/svn@1065036 9fca08f4-af9d-4005-b8df-a31f2cc04f65
Related tickets/PRs: * python/cpython#20236 * https://twistedmatrix.com/trac/ticket/10273 git-svn-id: file:///srv/repos/svn-community/svn@1065036 9fca08f4-af9d-4005-b8df-a31f2cc04f65
https://bugs.python.org/issue40679