You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument clinic uses some extra variables (like args, or noptargs, nargs etc.) for parsing. But there is a catch about these names, the generated code becomes wrong if there are any usages of them inside the signature. Encountered with this problem while working on *args support (in bpo-20291).
The possible solution is prefixing every argument in the parser with __clinic_ (_clinic{var}) for preventing any kind of conflict. I'll draft a PR for this issue.
After preparing the patch and transforming all arguments with a __clinic_ prefix, I saw there are some actions that are taken by relying on the parser code. An example;
In that case, self was already replaced with __clinic_self so that code doesn't work. IMHO there should be an identifier to distinguish these cases like; <self>->co_argc etc. When we see such defaults we can just replace them with the prefixed version.
FTR, if you try to use params named "self" in a class method (or "module" in a module level function), AC will bail and ask you to explicitly choose a custom name for the C variable. See #68395 (comment).
Activity
isidentical commentedon Feb 24, 2020
Argument clinic uses some extra variables (like args, or noptargs, nargs etc.) for parsing. But there is a catch about these names, the generated code becomes wrong if there are any usages of them inside the signature. Encountered with this problem while working on *args support (in bpo-20291).
The possible solution is prefixing every argument in the parser with __clinic_ (_clinic{var}) for preventing any kind of conflict. I'll draft a PR for this issue.
isidentical commentedon Feb 24, 2020
After preparing the patch and transforming all arguments with a __clinic_ prefix, I saw there are some actions that are taken by relying on the parser code. An example;
cpython/Objects/codeobject.c
Lines 616 to 631 in 8af4712
In that case, self was already replaced with __clinic_self so that code doesn't work. IMHO there should be an identifier to distinguish these cases like; <self>->co_argc etc. When we see such defaults we can just replace them with the prefixed version.
erlend-aasland commentedon May 1, 2023
Related to gh-68395. Can we close this after gh-104065, or do you want to follow another strategy?
erlend-aasland commentedon May 5, 2023
FTR, if you try to use params named "self" in a class method (or "module" in a module level function), AC will bail and ask you to explicitly choose a custom name for the C variable. See #68395 (comment).
I think we can close this after gh-104065 lands.
erlend-aasland commentedon May 5, 2023
(If you disagree, Batuhan, please open.)