This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: lib2to3 fails on a trailing comma after **kwargs in a function signature
Type: behavior Stage: resolved
Components: Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lukasz.langa Nosy List: lukasz.langa, ned.deily, serhiy.storchaka
Priority: normal Keywords: patch, patch

Created on 2018-03-13 02:50 by lukasz.langa, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6096 merged lukasz.langa, 2018-03-13 02:56
PR 6096 merged lukasz.langa, 2018-03-13 02:56
PR 6097 merged miss-islington, 2018-03-13 07:44
PR 6098 merged miss-islington, 2018-03-13 07:45
PR 6101 merged lukasz.langa, 2018-03-13 09:05
Messages (9)
msg313718 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 02:50
Title says all. I have a patch.
msg313719 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 02:50
Ned, I'd like this to make into 3.6.5 if at all possible.
msg313722 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-13 07:07
Does it support a trailing comma after *args or name=value?
msg313723 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-13 07:26
I'm not sure that a trailing comma after **kwargs in a function signature should be allowed in Python grammar. Reasons for allowing it after other arguments don't work here since **kwargs is always a last item in a signature.

But this ship perhaps is sailed.
msg313724 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 07:44
New changeset b51f5de71163f096d2d5229ede5379cdb284f651 by Łukasz Langa in branch 'master':
bpo-33064: lib2to3: support trailing comma after *args and **kwargs (#6096)
https://github.com/python/cpython/commit/b51f5de71163f096d2d5229ede5379cdb284f651
msg313725 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 07:49
Yes, this ship has sailed with Python 3.6.

I understand your logic and this is indeed why we didn't support this for a long time. However, people tend to grow muscle memory to add trailing commas and that was tripping them over for no real gain on our part. So this was added. The reason I found out about lib2to3 not following suit was that 3.6 users quickly started to put those trailing commas in and tools using lib2to3 were crashing on such files :) This proves it was worth it.
msg313726 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 07:52
Oh, and in terms of *calling* functions, now we can specify multiple unpacks, like:

  >>> f(
  ...   **d,
  ...   **e,
  ... )

so the extra comma for signatures simply makes it symmetrical in terms of appearance.
msg313728 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 08:08
New changeset b4c8871ca43d37be167ef5dbe9fb341922c04a9f by Łukasz Langa (Miss Islington (bot)) in branch '3.7':
bpo-33064: lib2to3: support trailing comma after *args and **kwargs (GH-6096) (#6097)
https://github.com/python/cpython/commit/b4c8871ca43d37be167ef5dbe9fb341922c04a9f
msg313729 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-03-13 08:32
New changeset 6a526f673878677032c02f7800ee13d4769f391a by Łukasz Langa (Miss Islington (bot)) in branch '3.6':
bpo-33064: lib2to3: support trailing comma after *args and **kwargs (GH-6096) (#6098)
https://github.com/python/cpython/commit/6a526f673878677032c02f7800ee13d4769f391a
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77245
2018-03-13 22:19:55lukasz.langasetkeywords: patch, patch
status: open -> closed
stage: patch review -> resolved
2018-03-13 09:05:58lukasz.langasetstage: commit review -> patch review
pull_requests: + pull_request5864
2018-03-13 08:32:36lukasz.langasetmessages: + msg313729
2018-03-13 08:08:06lukasz.langasetmessages: + msg313728
2018-03-13 07:52:19lukasz.langasetkeywords: patch, patch

messages: + msg313726
2018-03-13 07:49:12lukasz.langasetkeywords: patch, patch
resolution: fixed
messages: + msg313725

stage: patch review -> commit review
2018-03-13 07:45:58miss-islingtonsetpull_requests: + pull_request5861
2018-03-13 07:44:58miss-islingtonsetpull_requests: + pull_request5860
2018-03-13 07:44:53lukasz.langasetmessages: + msg313724
2018-03-13 07:26:01serhiy.storchakasetkeywords: patch, patch

messages: + msg313723
2018-03-13 07:07:38serhiy.storchakasetkeywords: patch, patch
nosy: + serhiy.storchaka
messages: + msg313722

2018-03-13 02:56:38lukasz.langasetkeywords: + patch
pull_requests: + pull_request5859
2018-03-13 02:56:37lukasz.langasetkeywords: + patch
pull_requests: + pull_request5858
2018-03-13 02:50:58lukasz.langasetnosy: + ned.deily
messages: + msg313719

type: behavior
stage: patch review
2018-03-13 02:50:30lukasz.langacreate