You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Merge branch 'master' into python-3.3-to-3.5
This commit is contained in:
@@ -25,6 +25,7 @@ from uncompyle6.semantics.consts import PRECEDENCE
|
|||||||
from uncompyle6.semantics.helper import is_lambda_mode
|
from uncompyle6.semantics.helper import is_lambda_mode
|
||||||
from uncompyle6.scanners.tok import Token
|
from uncompyle6.scanners.tok import Token
|
||||||
|
|
||||||
|
|
||||||
class ComprehensionMixin:
|
class ComprehensionMixin:
|
||||||
"""
|
"""
|
||||||
These functions hand nonterminal common actions that occur
|
These functions hand nonterminal common actions that occur
|
||||||
@@ -113,7 +114,10 @@ class ComprehensionMixin:
|
|||||||
elif node[0] == "load_closure":
|
elif node[0] == "load_closure":
|
||||||
cn = node[1]
|
cn = node[1]
|
||||||
|
|
||||||
elif self.version >= (3, 0) and node in ("generator_exp", "generator_exp_async"):
|
elif self.version >= (3, 0) and node in (
|
||||||
|
"generator_exp",
|
||||||
|
"generator_exp_async",
|
||||||
|
):
|
||||||
if node[0] == "load_genexpr":
|
if node[0] == "load_genexpr":
|
||||||
load_genexpr = node[0]
|
load_genexpr = node[0]
|
||||||
elif node[1] == "load_genexpr":
|
elif node[1] == "load_genexpr":
|
||||||
@@ -142,7 +146,9 @@ class ComprehensionMixin:
|
|||||||
if is_lambda_mode(self.compile_mode):
|
if is_lambda_mode(self.compile_mode):
|
||||||
p_save = self.p
|
p_save = self.p
|
||||||
self.p = get_python_parser(
|
self.p = get_python_parser(
|
||||||
self.version, compile_mode="exec", is_pypy=self.is_pypy,
|
self.version,
|
||||||
|
compile_mode="exec",
|
||||||
|
is_pypy=self.is_pypy,
|
||||||
)
|
)
|
||||||
tree = self.build_ast(code._tokens, code._customize, code)
|
tree = self.build_ast(code._tokens, code._customize, code)
|
||||||
self.p = p_save
|
self.p = p_save
|
||||||
@@ -397,8 +403,11 @@ class ComprehensionMixin:
|
|||||||
|
|
||||||
if n in ("list_for", "comp_for"):
|
if n in ("list_for", "comp_for"):
|
||||||
n_index = 3
|
n_index = 3
|
||||||
if ((n[2] == "store")
|
if (
|
||||||
or (self.version == (3, 0) and n[4] == "store") and not store):
|
(n[2] == "store")
|
||||||
|
or (self.version == (3, 0) and n[4] == "store")
|
||||||
|
and not store
|
||||||
|
):
|
||||||
if self.version == (3, 0):
|
if self.version == (3, 0):
|
||||||
store = n[4]
|
store = n[4]
|
||||||
n_index = 5
|
n_index = 5
|
||||||
@@ -407,9 +416,14 @@ class ComprehensionMixin:
|
|||||||
if not comp_store:
|
if not comp_store:
|
||||||
comp_store = store
|
comp_store = store
|
||||||
n = n[n_index]
|
n = n[n_index]
|
||||||
elif n in ("list_if", "list_if_not",
|
elif n in (
|
||||||
"list_if37", "list_if37_not",
|
"list_if",
|
||||||
"comp_if", "comp_if_not"):
|
"list_if_not",
|
||||||
|
"list_if37",
|
||||||
|
"list_if37_not",
|
||||||
|
"comp_if",
|
||||||
|
"comp_if_not",
|
||||||
|
):
|
||||||
have_not = n in ("list_if_not", "comp_if_not", "list_if37_not")
|
have_not = n in ("list_if_not", "comp_if_not", "list_if37_not")
|
||||||
if n in ("list_if37", "list_if37_not"):
|
if n in ("list_if37", "list_if37_not"):
|
||||||
n = n[1]
|
n = n[1]
|
||||||
@@ -518,7 +532,9 @@ class ComprehensionMixin:
|
|||||||
if self.compile_mode in ("listcomp",): # add other comprehensions to this list
|
if self.compile_mode in ("listcomp",): # add other comprehensions to this list
|
||||||
p_save = self.p
|
p_save = self.p
|
||||||
self.p = get_python_parser(
|
self.p = get_python_parser(
|
||||||
self.version, compile_mode="exec", is_pypy=self.is_pypy,
|
self.version,
|
||||||
|
compile_mode="exec",
|
||||||
|
is_pypy=self.is_pypy,
|
||||||
)
|
)
|
||||||
tree = self.build_ast(
|
tree = self.build_ast(
|
||||||
code._tokens, code._customize, code, is_lambda=self.is_lambda
|
code._tokens, code._customize, code, is_lambda=self.is_lambda
|
||||||
@@ -537,9 +553,7 @@ class ComprehensionMixin:
|
|||||||
if tree[0] in ("dom_start", "dom_start_opt"):
|
if tree[0] in ("dom_start", "dom_start_opt"):
|
||||||
tree = tree[1]
|
tree = tree[1]
|
||||||
|
|
||||||
while len(tree) == 1 or (
|
while len(tree) == 1 or (tree in ("stmt", "sstmt", "return", "return_expr")):
|
||||||
tree in ("stmt", "sstmt", "return", "return_expr")
|
|
||||||
):
|
|
||||||
self.prec = 100
|
self.prec = 100
|
||||||
tree = tree[1] if tree[0] in ("dom_start", "dom_start_opt") else tree[0]
|
tree = tree[1] if tree[0] in ("dom_start", "dom_start_opt") else tree[0]
|
||||||
return tree
|
return tree
|
||||||
|
Reference in New Issue
Block a user