Skip to content
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

Argument Clinic omits name of keyword-only parameter on _PyArg_BadArgument() call #81215

Closed
vstinner opened this issue May 24, 2019 · 8 comments
Labels
3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

BPO 37034
Nosy @vstinner, @serhiy-storchaka, @remilapeyre
PRs
  • bpo-37034: Display argument name on errors with keyword-only arguments with Argument Clinic #13593
  • [3.8] bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593). #15599
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-08-29.15:52:22.139>
    created_at = <Date 2019-05-24.10:29:45.200>
    labels = ['interpreter-core', 'type-bug', '3.8', '3.9']
    title = 'Argument Clinic omits name of keyword-only parameter on _PyArg_BadArgument() call'
    updated_at = <Date 2019-08-29.16:37:39.240>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-08-29.16:37:39.240>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-08-29.15:52:22.139>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2019-05-24.10:29:45.200>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37034
    keywords = ['patch']
    message_count = 8.0
    messages = ['343365', '343629', '344700', '344708', '350787', '350791', '350793', '350799']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'serhiy.storchaka', 'remi.lapeyre']
    pr_nums = ['13593', '15599']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37034'
    versions = ['Python 3.8', 'Python 3.9']

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner vstinner added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels May 24, 2019
    @remilapeyre
    Copy link
    Mannequin

    remilapeyre mannequin commented May 27, 2019

    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

    @serhiy-storchaka
    Copy link
    Member

    This is a bug. I intentionally committed the simpler code, but forgot to fix it later.

    @serhiy-storchaka serhiy-storchaka added 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels Jun 5, 2019
    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 5, 2019

    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.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 4901fe2 by Serhiy Storchaka (Rémi Lapeyre) in branch 'master':
    bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593)
    4901fe2

    @serhiy-storchaka
    Copy link
    Member

    New changeset 96631dc 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)
    96631dc

    @serhiy-storchaka
    Copy link
    Member

    Thank you Rémi!

    @vstinner
    Copy link
    Member Author

    Thanks, that's a great enhancement!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants