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, chris.jerdonek, xtreak
Date 2020-05-20.07:09:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589958541.62.0.734803330361.issue40679@roundup.psfhosted.org>
In-reply-to
Content
While trying to write tests, I stumbled across something interesting: _PyObject_FunctionString as discussed here ( https://bugs.python.org/issue37645 ) returns a string that also includes the module name where applicable.  For example, the module name is included behind the qualname in the following situation:

    >>> from random import Random
    >>> Random.seed(a=1, **{"a":2})
    Traceback (most recent call last):
      File "<pyshell#7>", line 1, in <module>
        Random.seed(a=1, **{"a":2})
    TypeError: random.Random.seed() got multiple values for keyword argument 'a'

or:

    >>> class A:
    ...    def foo(bar):
    ...         pass
    ...
    >>> A().foo(bar=1, **{"bar":2})
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: __main__.A.foo() got multiple values for keyword argument 'bar'

From what I can tell, this seems to happen mostly during the CALL_FUNCTION_EX instruction (unpacking *args and **kwargs), while we don't get this level of qualification during the actual do_call_core. Maybe _PyObject_FunctionString should ideally be used everywhere applicable, but there seems to be a different issue with that: the _PyEval_EvalCode function where the error handling occurs doesn't receive a reference to the function, only references to the function's code object and qualname (unless I'm missing to something).

Should the signature of _PyEval_EvalCode be modified? Or should we be satisfied with the half-measure of including the qualname but not the module (at least for now)? Is there a good reason for the different qualifiers for functions when encountering different types of invalid arguments?

There's also a block that I couldn't figure out how to reach in tests from Python code: at https://github.com/python/cpython/blob/master/Python/ceval.c#L4233 ("keywords must be strings" when passing as two arrays), I don't know how to reach this code in a way that isn't a SyntaxError first.
History
Date User Action Args
2020-05-20 07:09:01Dennis Sweeneysetrecipients: + Dennis Sweeney, chris.jerdonek, xtreak
2020-05-20 07:09:01Dennis Sweeneysetmessageid: <1589958541.62.0.734803330361.issue40679@roundup.psfhosted.org>
2020-05-20 07:09:01Dennis Sweeneylinkissue40679 messages
2020-05-20 07:09:01Dennis Sweeneycreate