classification
Title: Argument Clinic name conflict
Type: enhancement Stage:
Components: Argument Clinic Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, larry, pablogsal
Priority: low Keywords:

Created on 2020-02-24 17:30 by BTaskaya, last changed 2020-02-24 20:07 by BTaskaya.

Messages (2)
msg362599 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-02-24 17:30
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 issue 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.
msg362602 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-02-24 20:07
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;
https://github.com/python/cpython/blob/8af4712a16e4b7d1b60f1faec13cd7a88da95f6a/Objects/codeobject.c#L616-L631

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.
History
Date User Action Args
2020-02-24 20:07:45BTaskayasetmessages: + msg362602
2020-02-24 17:30:10BTaskayacreate