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

This commit is contained in:
rocky
2022-01-03 22:10:47 -05:00
20 changed files with 92 additions and 92 deletions

View File

@@ -473,7 +473,7 @@ class SourceWalker(GenericASTTraversal, object):
def is_return_none(self, node):
# Is there a better way?
ret = (
node[0] == "ret_expr"
node[0] == "return_expr"
and node[0][0] == "expr"
and node[0][0][0] == "LOAD_CONST"
and node[0][0][0].pattr is None
@@ -484,7 +484,7 @@ class SourceWalker(GenericASTTraversal, object):
# FIXME: should the SyntaxTree expression be folded into
# the global RETURN_NONE constant?
return ret or node == SyntaxTree(
"return", [SyntaxTree("ret_expr", [NONE]), Token("RETURN_VALUE")]
"return", [SyntaxTree("return_expr", [NONE]), Token("RETURN_VALUE")]
)
# Python 3.x can have be dead code as a result of its optimization?
@@ -596,7 +596,7 @@ class SourceWalker(GenericASTTraversal, object):
self.prec = p
self.prune()
def n_ret_expr(self, node):
def n_return_expr(self, node):
if len(node) == 1 and node[0] == "expr":
# If expr is yield we want parens.
self.prec = PRECEDENCE["yield"] - 1
@@ -604,7 +604,7 @@ class SourceWalker(GenericASTTraversal, object):
else:
self.n_expr(node)
n_ret_expr_or_cond = n_expr
n_return_expr_or_cond = n_expr
def n_bin_op(self, node):
"""bin_op (formerly "binary_expr") is the Python AST BinOp"""
@@ -1191,7 +1191,7 @@ class SourceWalker(GenericASTTraversal, object):
ast = self.build_ast(code._tokens, code._customize, code)
self.customize(code._customize)
# skip over: sstmt, stmt, return, ret_expr
# skip over: sstmt, stmt, return, return_expr
# and other singleton derivations
while len(ast) == 1 or (
ast in ("sstmt", "return") and ast[-1] in ("RETURN_LAST", "RETURN_VALUE")