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)
```


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to