[pypy-issue] Issue #2827: Trailing commas are occassionaly SyntaxErrors (pypy/pypy)

Devin Fee issues-reply at bitbucket.org
Wed May 9 23:13:05 EDT 2018


New issue 2827: Trailing commas are occassionaly SyntaxErrors
https://bitbucket.org/pypy/pypy/issues/2827/trailing-commas-are-occassionaly

Devin Fee:

I believe I've encountered a bug with trailing commas when creating functions:

```python
In [16]: def func(  # trailing comma, positional-or-keyword parameters: success!
    ...:         a=1,
    ...:         b=2,
    ...:     ):
    ...:     return a, b
    ...:
    ...:

In [17]: func(3, 4)
Out[17]: (3, 4)

In [18]: def func(  # trailing comma, a keyword-only parameter is introduced: FAILURE!
    ...:         a=1,
    ...:         *,
    ...:         b=2,
    ...:     ):
  File "<ipython-input-18-5878bb454ae5>", line 5
    ):
    ^
SyntaxError: invalid syntax


In [19]: def func(  # no trailing comma, a keyword-only parameter is introduced: success!
    ...:         a=1,
    ...:         *,
    ...:         b=2
    ...:     ):
    ...:     return a, b
    ...:
    ...:

In [20]: func(3, b=4)
Out[20]: (3, 4)
```




More information about the pypy-issue mailing list