Skip to content

Commit bfb0cf8

Browse files
committed
Revise handling of tuple arguments so that the variables names match
those used by compile.c. (test_grammar now depends on the names)
1 parent e20bd19 commit bfb0cf8

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

Lib/compiler/pyassem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def __init__(self, count, names):
495495
def __repr__(self):
496496
return "TupleArg(%s, %s)" % (self.count, self.names)
497497
def getName(self):
498-
return ".nested%d" % self.count
498+
return ".%d" % self.count
499499

500500
def getArgCount(args):
501501
argcount = len(args)

Lib/compiler/pycodegen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,10 @@ def finish(self):
11011101
self.emit('RETURN_VALUE')
11021102

11031103
def generateArgUnpack(self, args):
1104-
count = 0
1105-
for arg in args:
1104+
for i in range(len(args)):
1105+
arg = args[i]
11061106
if type(arg) == types.TupleType:
1107-
self.emit('LOAD_FAST', '.nested%d' % count)
1108-
count = count + 1
1107+
self.emit('LOAD_FAST', '.%d' % (i * 2))
11091108
self.unpackSequence(arg)
11101109

11111110
def unpackSequence(self, tup):
@@ -1184,13 +1183,14 @@ def generateArgList(arglist):
11841183
args = []
11851184
extra = []
11861185
count = 0
1187-
for elt in arglist:
1186+
for i in range(len(arglist)):
1187+
elt = arglist[i]
11881188
if type(elt) == types.StringType:
11891189
args.append(elt)
11901190
elif type(elt) == types.TupleType:
1191-
args.append(TupleArg(count, elt))
1192-
count = count + 1
1191+
args.append(TupleArg(i * 2, elt))
11931192
extra.extend(misc.flatten(elt))
1193+
count = count + 1
11941194
else:
11951195
raise ValueError, "unexpect argument type:", elt
11961196
return args + extra, count

Tools/compiler/compiler/pyassem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def __init__(self, count, names):
495495
def __repr__(self):
496496
return "TupleArg(%s, %s)" % (self.count, self.names)
497497
def getName(self):
498-
return ".nested%d" % self.count
498+
return ".%d" % self.count
499499

500500
def getArgCount(args):
501501
argcount = len(args)

Tools/compiler/compiler/pycodegen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,10 @@ def finish(self):
11011101
self.emit('RETURN_VALUE')
11021102

11031103
def generateArgUnpack(self, args):
1104-
count = 0
1105-
for arg in args:
1104+
for i in range(len(args)):
1105+
arg = args[i]
11061106
if type(arg) == types.TupleType:
1107-
self.emit('LOAD_FAST', '.nested%d' % count)
1108-
count = count + 1
1107+
self.emit('LOAD_FAST', '.%d' % (i * 2))
11091108
self.unpackSequence(arg)
11101109

11111110
def unpackSequence(self, tup):
@@ -1184,13 +1183,14 @@ def generateArgList(arglist):
11841183
args = []
11851184
extra = []
11861185
count = 0
1187-
for elt in arglist:
1186+
for i in range(len(arglist)):
1187+
elt = arglist[i]
11881188
if type(elt) == types.StringType:
11891189
args.append(elt)
11901190
elif type(elt) == types.TupleType:
1191-
args.append(TupleArg(count, elt))
1192-
count = count + 1
1191+
args.append(TupleArg(i * 2, elt))
11931192
extra.extend(misc.flatten(elt))
1193+
count = count + 1
11941194
else:
11951195
raise ValueError, "unexpect argument type:", elt
11961196
return args + extra, count

0 commit comments

Comments
 (0)