mirror of https://github.com/python/cpython.git
fix argcount generation for arg lists containing tuple unpacks
this is sort of a hack
This commit is contained in:
parent
65d4ea05d2
commit
2ce27b223b
|
@ -53,7 +53,7 @@ def __init__(self, args=(), name='?', filename='<?>',
|
|||
# XXX why is the default value for flags 3?
|
||||
self.insts = []
|
||||
# used by makeCodeObject
|
||||
self.argcount = len(args)
|
||||
self._getArgCount(args)
|
||||
self.code = ''
|
||||
self.consts = [docstring]
|
||||
self.filename = filename
|
||||
|
@ -67,6 +67,16 @@ def __init__(self, args=(), name='?', filename='<?>',
|
|||
self.last_addr = 0
|
||||
self.lnotab = ''
|
||||
|
||||
def _getArgCount(self, args):
|
||||
if args and args[0][0] == '.':
|
||||
for i in range(len(args)):
|
||||
if args[i][0] == '.':
|
||||
num = i
|
||||
self.argcount = num + 1
|
||||
else:
|
||||
self.argcount = len(args)
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "<bytecode: %d instrs>" % len(self.insts)
|
||||
|
||||
|
@ -231,7 +241,8 @@ def _convertArg(self, op, arg):
|
|||
return arg
|
||||
|
||||
nameOps = ('STORE_NAME', 'IMPORT_NAME', 'IMPORT_FROM',
|
||||
'STORE_ATTR', 'LOAD_ATTR', 'LOAD_NAME', 'DELETE_NAME')
|
||||
'STORE_ATTR', 'LOAD_ATTR', 'LOAD_NAME', 'DELETE_NAME',
|
||||
'DELETE_ATTR')
|
||||
localOps = ('LOAD_FAST', 'STORE_FAST', 'DELETE_FAST')
|
||||
globalOps = ('LOAD_GLOBAL', 'STORE_GLOBAL', 'DELETE_GLOBAL')
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ def __init__(self, args=(), name='?', filename='<?>',
|
|||
# XXX why is the default value for flags 3?
|
||||
self.insts = []
|
||||
# used by makeCodeObject
|
||||
self.argcount = len(args)
|
||||
self._getArgCount(args)
|
||||
self.code = ''
|
||||
self.consts = [docstring]
|
||||
self.filename = filename
|
||||
|
@ -67,6 +67,16 @@ def __init__(self, args=(), name='?', filename='<?>',
|
|||
self.last_addr = 0
|
||||
self.lnotab = ''
|
||||
|
||||
def _getArgCount(self, args):
|
||||
if args and args[0][0] == '.':
|
||||
for i in range(len(args)):
|
||||
if args[i][0] == '.':
|
||||
num = i
|
||||
self.argcount = num + 1
|
||||
else:
|
||||
self.argcount = len(args)
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "<bytecode: %d instrs>" % len(self.insts)
|
||||
|
||||
|
@ -231,7 +241,8 @@ def _convertArg(self, op, arg):
|
|||
return arg
|
||||
|
||||
nameOps = ('STORE_NAME', 'IMPORT_NAME', 'IMPORT_FROM',
|
||||
'STORE_ATTR', 'LOAD_ATTR', 'LOAD_NAME', 'DELETE_NAME')
|
||||
'STORE_ATTR', 'LOAD_ATTR', 'LOAD_NAME', 'DELETE_NAME',
|
||||
'DELETE_ATTR')
|
||||
localOps = ('LOAD_FAST', 'STORE_FAST', 'DELETE_FAST')
|
||||
globalOps = ('LOAD_GLOBAL', 'STORE_GLOBAL', 'DELETE_GLOBAL')
|
||||
|
||||
|
|
Loading…
Reference in New Issue