[New-bugs-announce] [issue24176] Incorrect parsing of unpacked expressions in call

Thomas Caswell report at bugs.python.org
Wed May 13 16:07:25 CEST 2015

New submission from Thomas Caswell:

On the current tip (changeset: 96023:4b5461dcd190) the following results in a syntax error

def test(a='a', b='b'):
    print(a, b)

opta = dict()
optb = dict(a=1, b=2)
test(**(opta or {}))  # <- works on all python
test(**optb or {})    # <- fails on current hg tip

This is suspected to be a result of https://hg.python.org/cpython/rev/a65f685ba8c0 

This was reported as an issue against sphinx (https://github.com/sphinx-doc/sphinx/pull/1889) and I was redirected here.

As suggested by Robert Lehmann suggests the issue is https://hg.python.org/cpython/rev/a65f685ba8c0#l1.33 which should be `** test`.  Making this change prevents the syntax error (patch attached).

components: Interpreter Core
files: unpack_grammar.patch
keywords: patch
messages: 243087
nosy: tcaswell
priority: normal
severity: normal
status: open
title: Incorrect parsing of unpacked expressions in call
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file39359/unpack_grammar.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list