You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
annotate args type need to be expr's not constants
This commit is contained in:
@@ -282,8 +282,7 @@ class Python3Parser(PythonParser):
|
|||||||
# int, float, str
|
# int, float, str
|
||||||
annotate_arg ::= LOAD_NAME
|
annotate_arg ::= LOAD_NAME
|
||||||
# LOAD_CONST is used in an annotation string
|
# LOAD_CONST is used in an annotation string
|
||||||
annotate_arg ::= LOAD_CONST
|
annotate_arg ::= expr
|
||||||
annotate_arg ::= LOAD_GLOBAL
|
|
||||||
|
|
||||||
# This stores the tuple of parameter names
|
# This stores the tuple of parameter names
|
||||||
# that have been annotated
|
# that have been annotated
|
||||||
|
@@ -97,8 +97,7 @@ def make_function3_annotate(self, node, isLambda, nested=1,
|
|||||||
j = annotate_last-1
|
j = annotate_last-1
|
||||||
l = -len(node)
|
l = -len(node)
|
||||||
while j >= l and node[j].type in ('annotate_arg' 'annotate_tuple'):
|
while j >= l and node[j].type in ('annotate_arg' 'annotate_tuple'):
|
||||||
annotate_args[annotate_tup[i]] = (node[j][0].attr,
|
annotate_args[annotate_tup[i]] = node[j][0]
|
||||||
node[j][0] in ('LOAD_CONST', 'LOAD_GLOBAL'))
|
|
||||||
i -= 1
|
i -= 1
|
||||||
j -= 1
|
j -= 1
|
||||||
|
|
||||||
@@ -227,14 +226,11 @@ def make_function3_annotate(self, node, isLambda, nested=1,
|
|||||||
self.write(', ')
|
self.write(', ')
|
||||||
i += 1
|
i += 1
|
||||||
pass
|
pass
|
||||||
elif n == 'annotate_arg':
|
|
||||||
from trepan.api import debug; debug()
|
|
||||||
pass
|
|
||||||
pass
|
pass
|
||||||
annotate_args = []
|
annotate_args = []
|
||||||
for n in node:
|
for n in node:
|
||||||
if n == 'annotate_arg':
|
if n == 'annotate_arg':
|
||||||
annotate_args.append(n[0].attr)
|
annotate_args.append(n[0])
|
||||||
elif n == 'annotate_tuple':
|
elif n == 'annotate_tuple':
|
||||||
t = n[0].attr
|
t = n[0].attr
|
||||||
if t[-1] == 'return':
|
if t[-1] == 'return':
|
||||||
@@ -243,7 +239,8 @@ def make_function3_annotate(self, node, isLambda, nested=1,
|
|||||||
pass
|
pass
|
||||||
last = len(annotate_args) - 1
|
last = len(annotate_args) - 1
|
||||||
for i in range(len(annotate_args)):
|
for i in range(len(annotate_args)):
|
||||||
self.write("%s: %s" % (annotate_args[i], t[i]))
|
self.write("%s: " % (t[i]))
|
||||||
|
self.preorder(annotate_args[i])
|
||||||
if i < last:
|
if i < last:
|
||||||
self.write(', ')
|
self.write(', ')
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user