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

PyArg_UnpackTuple is used with name="" #123446

Closed
denballakh opened this issue Aug 28, 2024 · 2 comments
Closed

PyArg_UnpackTuple is used with name="" #123446

denballakh opened this issue Aug 28, 2024 · 2 comments
Labels
extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@denballakh
Copy link
Contributor

denballakh commented Aug 28, 2024

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

@denballakh denballakh added the type-bug An unexpected behavior, bug, or error label Aug 28, 2024
@serhiy-storchaka
Copy link
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.

sobolevn added a commit to sobolevn/cpython that referenced this issue Aug 29, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Aug 29, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Aug 29, 2024
…_csv` module (pythonGH-123462)

(cherry picked from commit 58ce131)

Co-authored-by: sobolevn <mail@sobolevn.me>
@picnixz picnixz added interpreter-core (Objects, Python, Grammar, and Parser dirs) extension-modules C modules in the Modules dir labels Aug 29, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Aug 29, 2024
@sobolevn
Copy link
Member

Thanks for the report! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir 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

4 participants