@@ -1493,23 +1493,29 @@ def n_build_list(self, node):
14931493 self .prec = 100
14941494 lastnode = node .pop ()
14951495 lastnodetype = lastnode .type
1496+
1497+ # If this build list is inside a CALL_FUNCTION_VAR,
1498+ # then the first * has already been printed.
1499+ # Until I have a better way to check for CALL_FUNCTION_VAR,
1500+ # will assume that if the text ends in *.
1501+ last_was_star = self .f .getvalue ().endswith ('*' )
1502+
14961503 have_star = False
1497- if lastnodetype .startswith ('BUILD_LIST' ):
1498- # 3.5+ has BUILD_LIST_UNPACK
1499- if lastnodetype == 'BUILD_LIST_UNPACK' :
1500- # FIXME: need to handle range of BUILD_LIST_UNPACK
1501- have_star = True
1502- endchar = ''
1503- else :
1504- self .write ('[' ); endchar = ']'
1505- elif lastnodetype .startswith ('BUILD_TUPLE' ):
1506- self .write ('(' ); endchar = ')'
1507- elif lastnodetype .startswith ('BUILD_SET' ):
1508- self .write ('{' ); endchar = '}'
1509- elif lastnodetype .startswith ('ROT_TWO' ):
1510- self .write ('(' ); endchar = ')'
1504+ if lastnodetype .endswith ('UNPACK' ):
1505+ # FIXME: need to handle range of BUILD_LIST_UNPACK
1506+ have_star = True
1507+ endchar = ''
15111508 else :
1512- raise 'Internal Error: n_build_list expects list or tuple'
1509+ if lastnodetype .startswith ('BUILD_LIST' ):
1510+ self .write ('[' ); endchar = ']'
1511+ elif lastnodetype .startswith ('BUILD_TUPLE' ):
1512+ self .write ('(' ); endchar = ')'
1513+ elif lastnodetype .startswith ('BUILD_SET' ):
1514+ self .write ('{' ); endchar = '}'
1515+ elif lastnodetype .startswith ('ROT_TWO' ):
1516+ self .write ('(' ); endchar = ')'
1517+ else :
1518+ raise 'Internal Error: n_build_list expects list or tuple'
15131519
15141520 flat_elems = []
15151521 for elem in node :
@@ -1536,8 +1542,13 @@ def n_build_list(self, node):
15361542 sep += '\n ' + self .indent + INDENT_PER_LEVEL [:- 1 ]
15371543 else :
15381544 if sep != '' : sep += ' '
1539- if have_star :
1540- sep += '*'
1545+ if not last_was_star :
1546+ if have_star :
1547+ sep += '*'
1548+ pass
1549+ pass
1550+ else :
1551+ last_was_star = False
15411552 self .write (sep , value )
15421553 sep = ','
15431554 if lastnode .attr == 1 and lastnodetype .startswith ('BUILD_TUPLE' ):
0 commit comments