`f(kw=a, *b)` with keyword argument before star arguments isn’t evaluated left-to-right
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
def f(a, kw):
pass
f(kw=print(1), *[print(2)])
In Python 3.4.10 and earlier, this prints 1 then 2, but in Python 3.5.0 and later, this prints 2 then 1.
This seems like a bug of some kind. Given that ast.parse() doesn’t distinguish between f(kw=a, *b) and f(*b, kw=a), perhaps the bug is that a keyword argument is allowed before star arguments at all—we already disallow f(kw=a, b), f(**a, b), and f(**a, *b).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided f(kw=print(1), *[print(2)]) example on the affected Python versions, then trace how CPython parses and evaluates calls containing keyword arguments and star arguments. Done means the behavior is corrected consistently, or the invalid argument ordering is rejected if that is the chosen resolution; the issue names no source files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100