You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Annotation field can be unicode...
When deparsing Python 3.x from Python 2.
This commit is contained in:
@@ -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?
|
||||||
|
Reference in New Issue
Block a user