← 输入框|github.com|刷新
Skip to content

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

Closed

Description

@vstinner
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']

    Activity

    1. vstinner commented on May 24, 2019

      @vstinner
      MemberAuthor

      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.

    2. remilapeyre commented on May 27, 2019

      remilapeyremannequin
      Mannequin

      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
    3. serhiy-storchaka commented on Jun 5, 2019

      @serhiy-storchaka
      Member

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

    4. vstinner commented on Jun 5, 2019

      @vstinner
      MemberAuthor

      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.

    5. serhiy-storchaka commented on Aug 29, 2019

      @serhiy-storchaka
      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

    6. serhiy-storchaka commented on Aug 29, 2019

      @serhiy-storchaka
      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

    7. serhiy-storchaka commented on Aug 29, 2019

      @serhiy-storchaka
      Member

      Thank you Rémi!

    8. vstinner commented on Aug 29, 2019

      @vstinner
      MemberAuthor

      Thanks, that's a great enhancement!

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)end of life3.9 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions