Annotation field can be unicode...

When deparsing Python 3.x from Python 2.
This commit is contained in:
rocky
2017-09-26 09:53:26 -04:00
parent ea75bcf47e
commit 1a627ba207

View File

@@ -18,6 +18,7 @@ that a later phase can turn into a sequence of ASCII text.
from uncompyle6.parser import PythonParser, PythonParserSingle, nop_func from uncompyle6.parser import PythonParser, PythonParserSingle, nop_func
from uncompyle6.parsers.astnode import AST from uncompyle6.parsers.astnode import AST
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from xdis import PYTHON3
class Python3Parser(PythonParser): class Python3Parser(PythonParser):
@@ -890,8 +891,11 @@ class Python3Parser(PythonParser):
elif lhs == 'annotate_tuple': elif lhs == 'annotate_tuple':
return not isinstance(tokens[first].attr, tuple) return not isinstance(tokens[first].attr, tuple)
elif lhs == 'kwarg': elif lhs == 'kwarg':
return not (isinstance(tokens[first].attr, unicode) or arg = tokens[first].attr
isinstance(tokens[first].attr, str)) if PYTHON3:
return not isinstance(arg, str)
else:
return not (isinstance(arg, str) or isinstance(arg, unicode))
elif lhs == 'while1elsestmt': elif lhs == 'while1elsestmt':
# if SETUP_LOOP target spans the else part, then this is # if SETUP_LOOP target spans the else part, then this is
# not while1else. Also do for whileTrue? # not while1else. Also do for whileTrue?