You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Python 3.5 CALL_FUNCTION_VAR handling
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,8 @@
|
|||||||
# From sql/schema.py and 3.5 _strptime.py
|
# From sql/schema.py and 3.5 _strptime.py
|
||||||
# Note that kwargs comes before "positional" args
|
# Note that kwargs comes before "positional" args
|
||||||
|
|
||||||
|
# RUNNABLE!
|
||||||
|
|
||||||
def tometadata(self, metadata, schema, Table, args, name=None):
|
def tometadata(self, metadata, schema, Table, args, name=None):
|
||||||
table = Table(
|
table = Table(
|
||||||
name, metadata, schema=schema,
|
name, metadata, schema=schema,
|
||||||
@@ -23,16 +25,18 @@ def Time2Internaldate(date_time):
|
|||||||
assert Time2Internaldate(time.localtime())
|
assert Time2Internaldate(time.localtime())
|
||||||
|
|
||||||
# From 3.5.5 tkinter/dialog.py
|
# From 3.5.5 tkinter/dialog.py
|
||||||
def test_varargs0_ext(self):
|
def test_varargs0_ext():
|
||||||
try:
|
try:
|
||||||
{}.__contains__(*())
|
{}.__contains__(*())
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
test_varargs0_ext()
|
||||||
|
|
||||||
# From 3.4.6 tkinter/dialog.py
|
# From 3.4.6 tkinter/dialog.py
|
||||||
# Bug is in position of *cnf.
|
# Bug is in position of *cnf.
|
||||||
|
|
||||||
def __init__(self, master=None, cnf={}):
|
def __init__(self, cnf={}):
|
||||||
self.num = self.tk.call(
|
self.num = self.tk.call(
|
||||||
'tk_dialog', self._w,
|
'tk_dialog', self._w,
|
||||||
cnf['title'], cnf['text'],
|
cnf['title'], cnf['text'],
|
||||||
|
@@ -254,8 +254,8 @@ def customize_for_version(self, is_pypy, version):
|
|||||||
elif key.kind.startswith('CALL_FUNCTION_VAR'):
|
elif key.kind.startswith('CALL_FUNCTION_VAR'):
|
||||||
# CALL_FUNCTION_VAR's top element of the stack contains
|
# CALL_FUNCTION_VAR's top element of the stack contains
|
||||||
# the variable argument list, then comes
|
# the variable argument list, then comes
|
||||||
# annotation args, then keyword args,
|
# annotation args, then keyword args.
|
||||||
# and finally on the most bottom (but position 1
|
# In the most least-top-most stack entry, but position 1
|
||||||
# in node order, the positional args.
|
# in node order, the positional args.
|
||||||
argc = node[-1].attr
|
argc = node[-1].attr
|
||||||
nargs = argc & 0xFF
|
nargs = argc & 0xFF
|
||||||
@@ -320,11 +320,15 @@ def customize_for_version(self, is_pypy, version):
|
|||||||
key = key[i]
|
key = key[i]
|
||||||
pass
|
pass
|
||||||
if key.kind.startswith('CALL_FUNCTION_VAR_KW'):
|
if key.kind.startswith('CALL_FUNCTION_VAR_KW'):
|
||||||
# Python 3.5 changes the stack position of *args. kwargs come
|
# Python 3.5 changes the stack position of
|
||||||
# after *args whereas in earlier Pythons, *args is at the end
|
# *args: kwargs come after *args whereas
|
||||||
# which simplifies things from our perspective.
|
# in earlier Pythons, *args is at the end
|
||||||
# Python 3.6+ replaces CALL_FUNCTION_VAR_KW with CALL_FUNCTION_EX
|
# which simplifies things from our
|
||||||
# We will just swap the order to make it look like earlier Python 3.
|
# perspective. Python 3.6+ replaces
|
||||||
|
# CALL_FUNCTION_VAR_KW with
|
||||||
|
# CALL_FUNCTION_EX We will just swap the
|
||||||
|
# order to make it look like earlier
|
||||||
|
# Python 3.
|
||||||
entry = table[key.kind]
|
entry = table[key.kind]
|
||||||
kwarg_pos = entry[2][1]
|
kwarg_pos = entry[2][1]
|
||||||
args_pos = kwarg_pos - 1
|
args_pos = kwarg_pos - 1
|
||||||
@@ -335,7 +339,15 @@ def customize_for_version(self, is_pypy, version):
|
|||||||
args_pos = kwarg_pos
|
args_pos = kwarg_pos
|
||||||
kwarg_pos += 1
|
kwarg_pos += 1
|
||||||
elif key.kind.startswith('CALL_FUNCTION_VAR'):
|
elif key.kind.startswith('CALL_FUNCTION_VAR'):
|
||||||
nargs = node[-1].attr & 0xFF
|
# CALL_FUNCTION_VAR's top element of the stack contains
|
||||||
|
# the variable argument list, then comes
|
||||||
|
# annotation args, then keyword args.
|
||||||
|
# In the most least-top-most stack entry, but position 1
|
||||||
|
# in node order, the positional args.
|
||||||
|
argc = node[-1].attr
|
||||||
|
nargs = argc & 0xFF
|
||||||
|
kwargs = (argc >> 8) & 0xFF
|
||||||
|
# FIXME: handle annotation args
|
||||||
if nargs > 0:
|
if nargs > 0:
|
||||||
template = ('%c(%C, ', 0, (1, nargs+1, ', '))
|
template = ('%c(%C, ', 0, (1, nargs+1, ', '))
|
||||||
else:
|
else:
|
||||||
@@ -343,16 +355,14 @@ def customize_for_version(self, is_pypy, version):
|
|||||||
self.template_engine(template, node)
|
self.template_engine(template, node)
|
||||||
|
|
||||||
args_node = node[-2]
|
args_node = node[-2]
|
||||||
if args_node == 'pos_arg':
|
if args_node in ('pos_arg', 'expr'):
|
||||||
args_node = args_node[0]
|
|
||||||
if args_node == 'expr':
|
|
||||||
args_node = args_node[0]
|
args_node = args_node[0]
|
||||||
if args_node == 'build_list_unpack':
|
if args_node == 'build_list_unpack':
|
||||||
template = ('*%P)', (0, len(args_node)-1, ', *', 100))
|
template = ('*%P)', (0, len(args_node)-1, ', *', 100))
|
||||||
self.template_engine(template, args_node)
|
self.template_engine(template, args_node)
|
||||||
else:
|
else:
|
||||||
if len(node) > 3:
|
if len(node) - nargs > 3:
|
||||||
template = ('*%c, %C)', 1, (2, -1, ', '))
|
template = ('*%c, %C)', 1, (nargs+kwargs+1, -1, ', '))
|
||||||
else:
|
else:
|
||||||
template = ('*%c)', 1)
|
template = ('*%c)', 1)
|
||||||
self.template_engine(template, node)
|
self.template_engine(template, node)
|
||||||
|
Reference in New Issue
Block a user