◐ Shell
clean mode source ↗

gh-64490: Fix bugs in argument clinic varargs processing by colorfulappl · Pull Request #32092 · python/cpython

added 3 commits

March 24, 2022 15:21
Python allows at most *one* vararg in one function.
Remove the improper varargs check which allows function definition like
```
    *vararg1: object
    *vararg2: object
```
in argument clinic.
Variable `vararg` indicates the index of vararg in parameter list.
While copying kwargs to `buf`, the index `i` should not add `vararg`, which leads to an out-of-bound bug.

When there are positional args, vararg and keyword args in a function definition, in which case `vararg` > 1, this bug can be triggered.

e.g.
```
    pos: object
    *args: object
    kw: object
```
The calculation of noptargs is incorrect when there is a vararg.
This bug prevents parsed arguments passing to XXXX_impl function.

e.g.
Define function
```
    *args: object
    kw: object
```
and pass kw=1 to the function, the `kw` parameter won't receive the pass in value.

erlend-aasland

# Conflicts:
#	Lib/test/clinic.test

@blurb-it

@colorfulappl

@erlend-aasland erlend-aasland changed the title bpo-20291: Fix bugs in argument clinic varargs processing gh-64490: Fix bugs in argument clinic varargs processing

Aug 11, 2022

@colorfulappl

# Conflicts:
#	Lib/test/clinic.test

@colorfulappl

@colorfulappl

erlend-aasland

kumaraditya303

# Conflicts:
#	Lib/test/test_clinic.py
#	Modules/_testclinic.c
#	Modules/clinic/_testclinic.c.h

colorfulappl added a commit to colorfulappl/cpython that referenced this pull request

Dec 20, 2022