Skip to content

gh-136327: Fix inconsistent TypeError messages regarding invalid values after * and ** #136395

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Tapeline
Copy link
Contributor

@Tapeline Tapeline commented Jul 7, 2025

Solved removing function name from error message entirely

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 7, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@Tapeline Tapeline changed the title gh-12345: Fix inconsistent TypeError messages regarding invalid values after * and ** gh-136327: Fix inconsistent TypeError messages regarding invalid values after * and ** Jul 7, 2025
funcstr, Py_TYPE(args)->tp_name);
Py_DECREF(funcstr);
}
_PyErr_Format(tstate, PyExc_TypeError,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not to use %T formatter here? IIUC it is preferable now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nikita's suggestions on removing the function name entirely were motivated by the fact that getting this name is not fast and does not add much value (in fact, none at all). I've looked into the %T specification, and it seems to do x2 of work we just got rid of, so I doubt that that would be a positive change. Anyway, we're waiting on Mark's review on that, maybe he has another opinion

Copy link
Contributor

@efimov-mikhail efimov-mikhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are at it :)

Comment on lines +331 to 332
TypeError: Value after ** must be a mapping, \
not function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TypeError: Value after ** must be a mapping, \
not function
TypeError: Value after ** must be a mapping, not function

Please, fix similar cases :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants