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.

classification
Title: Argument Clinic omits name of keyword-only parameter on _PyArg_BadArgument() call
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: remi.lapeyre, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2019-05-24 10:29 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13593 merged remi.lapeyre, 2019-05-27 14:13
PR 15599 merged serhiy.storchaka, 2019-08-29 15:09
Messages (8)
msg343365 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-24 10:29
Example of generated code:

    if (!PyBytes_Check(args[15])) {
        _PyArg_BadArgument("replace", 16, "bytes", args[15]);
        goto exit;
    }

Error message:

TypeError: replace() argument 16 must be bytes, not tuple

It is the 'lnotab' parameter which is a keywoard-only parameter. I expect the parameter name in the error message.

Note: I got this error while implementing bpo-37032.
msg343629 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-05-27 14:15
With the attached PR, the error message is now:

>>> def f(): pass
... 
>>> code = f.__code__
>>> code.replace(co_lnotab=4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: replace() argument 'co_lnotab' must be bytes, not int
msg344700 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-05 10:31
This is a bug. I intentionally committed the simpler code, but forgot to fix it later.
msg344708 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-05 11:54
> This is a bug. I intentionally committed the simpler code, but forgot to fix it later.

I suggest to also apply the fix to 3.8 in that case.
msg350787 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-29 14:49
New changeset 4901fe274bc82b95dc89bcb3de8802a3dfedab32 by Serhiy Storchaka (Rémi Lapeyre) in branch 'master':
bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593)
https://github.com/python/cpython/commit/4901fe274bc82b95dc89bcb3de8802a3dfedab32
msg350791 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-29 15:30
New changeset 96631dcb11c2786f470d4586bf23ecca14361506 by Serhiy Storchaka in branch '3.8':
[3.8] bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593). (GH-15599)
https://github.com/python/cpython/commit/96631dcb11c2786f470d4586bf23ecca14361506
msg350793 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-29 15:52
Thank you Rémi!
msg350799 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-08-29 16:37
Thanks, that's a great enhancement!
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81215
2019-08-29 16:37:39vstinnersetmessages: + msg350799
2019-08-29 15:52:22serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg350793

stage: patch review -> resolved
2019-08-29 15:30:02serhiy.storchakasetmessages: + msg350791
2019-08-29 15:09:52serhiy.storchakasetpull_requests: + pull_request15275
2019-08-29 14:49:12serhiy.storchakasetmessages: + msg350787
2019-06-05 11:54:27vstinnersetmessages: + msg344708
2019-06-05 10:31:04serhiy.storchakasettype: behavior
messages: + msg344700
versions: + Python 3.9
2019-05-27 14:15:47remi.lapeyresetnosy: + remi.lapeyre
messages: + msg343629
2019-05-27 14:13:42remi.lapeyresetkeywords: + patch
stage: patch review
pull_requests: + pull_request13500
2019-05-24 10:29:45vstinnercreate