Skip to content

PyArg_UnpackTuple is used with name="" #123446

Description

@denballakh

Bug report

Bug description:

PyArg_UnpackTuple(args, "", causes empty name to be used in error messages:

>>> str.join.__get__()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError:  expected at least 1 argument, got 0
#         ^^

>>> try: str.join.__get__()
... except Exception as e: exc = e
...
>>> str(exc)
' expected at least 1 argument, got 0'
#^

According to my quick search, PyArg_UnpackTuple(args, "", is used 10 times in Objects/typeobject.c and 3 times in Modules/_csv.c.

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. serhiy-storchaka commented on Aug 29, 2024

    @serhiy-storchaka
    Member

    I agree, this is a misuse. The right use is to pass NULL as the name, or better provide some related name if this is possible.

  2. added a commit that references this issue on Aug 29, 2024
  3. added a commit that references this issue on Aug 29, 2024
  4. added 3 commits that reference this issue on Aug 29, 2024
  5. added 2 commits that reference this issue on Aug 29, 2024
  6. sobolevn commented on Aug 30, 2024

    @sobolevn
    Member

    Thanks for the report! 👍

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

    extension-modulesC modules in the Modules dirinterpreter-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