Fix tuple unpacking for special case

This commit is contained in:
Dave Halter
2019-05-31 17:07:51 +02:00
parent cdc9520c9d
commit d9332aec8c
3 changed files with 9 additions and 1 deletions

View File

@@ -584,7 +584,7 @@ def unpack_tuple_to_dict(context, types, exprlist):
""" """
if exprlist.type == 'name': if exprlist.type == 'name':
return {exprlist.value: types} return {exprlist.value: types}
elif exprlist.type == 'atom' and exprlist.children[0] in '([': elif exprlist.type == 'atom' and exprlist.children[0] in ('(', '['):
return unpack_tuple_to_dict(context, types, exprlist.children[1]) return unpack_tuple_to_dict(context, types, exprlist.children[1])
elif exprlist.type in ('testlist', 'testlist_comp', 'exprlist', elif exprlist.type in ('testlist', 'testlist_comp', 'exprlist',
'testlist_star_expr'): 'testlist_star_expr'):

View File

@@ -79,6 +79,11 @@ for a3, b3 in (1,""), (1,""), (1,""):
a3 a3
#? str() #? str()
b3 b3
for (a3, b3) in (1,""), (1,""), (1,""):
#? int()
a3
#? str()
b3
for a4, (b4, c4) in (1,("", list)), (1,("", list)): for a4, (b4, c4) in (1,("", list)), (1,("", list)):
#? int() #? int()

View File

@@ -27,6 +27,9 @@ a[0]
a = [a for a,b in [(1,'')]] a = [a for a,b in [(1,'')]]
#? int() #? int()
a[0] a[0]
a = [a for (a,b) in [(1,'')]]
#? int()
a[0]
arr = [1,''] arr = [1,'']
a = [a for a in arr] a = [a for a in arr]