Merge branch 'master' into python-3.3-to-3.5

This commit is contained in:
rocky
2022-11-04 00:50:01 -04:00

View File

@@ -25,6 +25,7 @@ from uncompyle6.semantics.consts import PRECEDENCE
from uncompyle6.semantics.helper import is_lambda_mode
from uncompyle6.scanners.tok import Token
class ComprehensionMixin:
"""
These functions hand nonterminal common actions that occur
@@ -113,7 +114,10 @@ class ComprehensionMixin:
elif node[0] == "load_closure":
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":
load_genexpr = node[0]
elif node[1] == "load_genexpr":
@@ -142,7 +146,9 @@ class ComprehensionMixin:
if is_lambda_mode(self.compile_mode):
p_save = self.p
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)
self.p = p_save
@@ -397,8 +403,11 @@ class ComprehensionMixin:
if n in ("list_for", "comp_for"):
n_index = 3
if ((n[2] == "store")
or (self.version == (3, 0) and n[4] == "store") and not store):
if (
(n[2] == "store")
or (self.version == (3, 0) and n[4] == "store")
and not store
):
if self.version == (3, 0):
store = n[4]
n_index = 5
@@ -407,9 +416,14 @@ class ComprehensionMixin:
if not comp_store:
comp_store = store
n = n[n_index]
elif n in ("list_if", "list_if_not",
"list_if37", "list_if37_not",
"comp_if", "comp_if_not"):
elif n in (
"list_if",
"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")
if n in ("list_if37", "list_if37_not"):
n = n[1]
@@ -518,7 +532,9 @@ class ComprehensionMixin:
if self.compile_mode in ("listcomp",): # add other comprehensions to this list
p_save = self.p
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, is_lambda=self.is_lambda
@@ -537,9 +553,7 @@ class ComprehensionMixin:
if tree[0] in ("dom_start", "dom_start_opt"):
tree = tree[1]
while len(tree) == 1 or (
tree in ("stmt", "sstmt", "return", "return_expr")
):
while len(tree) == 1 or (tree in ("stmt", "sstmt", "return", "return_expr")):
self.prec = 100
tree = tree[1] if tree[0] in ("dom_start", "dom_start_opt") else tree[0]
return tree