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 to parse a ** of a conditional expression
Type: Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.9, Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: lib2to3 doesn't parse f(*[] or [])
View: 33348
Assigned To: Nosy List: benjamin.peterson, gregory.p.smith, salty-horse, xtreak
Priority: normal Keywords:

Created on 2018-01-04 23:28 by gregory.p.smith, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
repro_2to3_prob.py gregory.p.smith, 2018-01-04 23:28
Messages (2)
msg309488 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2018-01-04 23:28
see the attached sample code demonstrating the problem.

basically lib2to3 fails to parse:

  dummy(**kwargs if kwargs else dict())

with an error like:

    raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=1, value='if', context=(' ', (3, 21))
msg333641 - (view) Author: Ori Avtalion (salty-horse) * Date: 2019-01-14 20:41
This can be circumvented by adding parenthesis:

  dummy(**(kwargs if kwargs else dict()))
History
Date User Action Args
2022-04-11 14:58:56adminsetgithub: 76677
2019-10-24 05:56:26gregory.p.smithsetstatus: open -> closed
superseder: lib2to3 doesn't parse f(*[] or [])
stage: resolved
resolution: duplicate
versions: + Python 3.8, Python 3.9, - Python 3.6
2019-01-14 20:41:16salty-horsesetnosy: + salty-horse
messages: + msg333641
2018-09-14 09:03:31xtreaksetnosy: + xtreak
2018-01-04 23:49:12serhiy.storchakasetnosy: + benjamin.peterson
2018-01-04 23:28:09gregory.p.smithcreate