This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dennis Sweeney
Recipients Dennis Sweeney
Date 2020-05-21.06:08:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590041322.58.0.905354707279.issue40706@roundup.psfhosted.org>
In-reply-to
Content
When I was looking into https://bugs.python.org/issue40679, I couldn't come up with a test case for the following block, so I added a print statement:

--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4179,6 +4179,7 @@ _PyEval_EvalCode(PyThreadState *tstate,
         Py_ssize_t j;

         if (keyword == NULL || !PyUnicode_Check(keyword)) {
+            printf("THIS CODE WAS RUN!\n");
             _PyErr_Format(tstate, PyExc_TypeError,
                           "%U() keywords must be strings",
                           qualname);

I ran the entire test suite and got no such "THIS CODE WAS RUN!". It looks like this is a double-check of the (worse -- no function name) error message produced by the changes at https://github.com/python/cpython/commit/0567786d26348aa7eaf0ab1b5d038fdabe409d92. For example:

    py -3.7 -c "f = lambda x: None; f(**{1:1})"
      ...
    TypeError: <lambda>() keywords must be strings

    py -3.8 -c "f = lambda x: None; f(**{1:1})"
      ...
    TypeError: <lambda>() keywords must be strings

    py -3.9 -c "f = lambda x: None; f(**{1:1})"
      ...
    TypeError: keywords must be strings

So:

* Can this check be eliminated since it's unreachable from Python?

* Otherwise, is there some reason a C caller would need this check? And could it be replaced by and assert?

* If it shouldn't change, then is there a good way to add test coverage?
History
Date User Action Args
2020-05-21 06:08:42Dennis Sweeneysetrecipients: + Dennis Sweeney
2020-05-21 06:08:42Dennis Sweeneysetmessageid: <1590041322.58.0.905354707279.issue40706@roundup.psfhosted.org>
2020-05-21 06:08:42Dennis Sweeneylinkissue40706 messages
2020-05-21 06:08:42Dennis Sweeneycreate