Bowler icon indicating copy to clipboard operation
Bowler copied to clipboard

Failed to parse on **(expr) without parens

Open thatch opened this issue 5 years ago • 3 comments

This appears to be valid in 3.6, 3.7, and 3.8.0a2:

def func(**kwargs):
    print(kwargs)

x = {'a': '1'}
func(**x or {})

Bowler can't parse it, I'm wondering if there is a fissix issue? We should also show the error near "except ParseError" in bowler/tool.py.

thatch avatar Apr 05 '19 22:04 thatch

This appears to be an issue with lib2to3 on all three versions mentioned above:

from lib2to3.pgen2 import driver
from lib2to3 import pygram, pytree

def main():
    with open("t.py") as input:
        data = input.read()
    d = driver.Driver(
        pygram.python_grammar_no_print_statement,
        convert=pytree.convert,
    )
    tree = d.parse_string(data)
    print(tree)

if __name__ == '__main__':
    main()

thatch avatar Apr 05 '19 22:04 thatch

https://github.com/python/cpython/pull/12702 and https://github.com/python/cpython/pull/12703 opened upstream for this

amyreese avatar Apr 08 '19 20:04 amyreese

This has been fixed in blib2to3 in Black. Maybe I should split it out into its own module, seeing how there's not much interest in backporting changes like https://github.com/python/cpython/pull/6586 and https://github.com/python/cpython/pull/6588

zsol avatar Jun 19 '19 07:06 zsol