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:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2021 Rocky Bernstein
|
# Copyright (c) 2015-2022 Rocky Bernstein
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
# Copyright (c) 1999 John Aycock
|
# Copyright (c) 1999 John Aycock
|
||||||
@@ -577,10 +577,10 @@ class PythonParser(GenericASTBuilder):
|
|||||||
ret_expr_or_cond ::= ret_expr
|
ret_expr_or_cond ::= ret_expr
|
||||||
ret_expr_or_cond ::= if_exp_ret
|
ret_expr_or_cond ::= if_exp_ret
|
||||||
|
|
||||||
stmt ::= return_lambda
|
stmt ::= return_expr_lambda
|
||||||
|
|
||||||
return_lambda ::= ret_expr RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
return_expr_lambda ::= ret_expr RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||||
return_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
return_expr_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
||||||
|
|
||||||
compare ::= compare_chained
|
compare ::= compare_chained
|
||||||
compare ::= compare_single
|
compare ::= compare_single
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2017-2021 Rocky Bernstein
|
# Copyright (c) 2017-2022 Rocky Bernstein
|
||||||
"""
|
"""
|
||||||
spark grammar differences over Python2 for Python 2.6.
|
spark grammar differences over Python2 for Python 2.6.
|
||||||
"""
|
"""
|
||||||
@@ -317,7 +317,7 @@ class Python26Parser(Python2Parser):
|
|||||||
return_lambda ::= RETURN_END_IF_LAMBDA
|
return_lambda ::= RETURN_END_IF_LAMBDA
|
||||||
return_lambda ::= RETURN_VALUE_LAMBDA
|
return_lambda ::= RETURN_VALUE_LAMBDA
|
||||||
|
|
||||||
compare_chained2 ::= expr COMPARE_OP return_lambda
|
compare_chained2 ::= expr COMPARE_OP return_expr_lambda
|
||||||
|
|
||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
||||||
stmt ::= if_exp_lambda
|
stmt ::= if_exp_lambda
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2021 Rocky Bernstein
|
# Copyright (c) 2015-2022 Rocky Bernstein
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
# Copyright (c) 1999 John Aycock
|
# Copyright (c) 1999 John Aycock
|
||||||
@@ -711,9 +711,9 @@ class Python3Parser(PythonParser):
|
|||||||
stmt ::= if_exp_lambda
|
stmt ::= if_exp_lambda
|
||||||
stmt ::= if_exp_not_lambda
|
stmt ::= if_exp_not_lambda
|
||||||
if_expr_lambda ::= expr jmp_false expr return_if_lambda
|
if_expr_lambda ::= expr jmp_false expr return_if_lambda
|
||||||
return_lambda LAMBDA_MARKER
|
return_expr_lambda LAMBDA_MARKER
|
||||||
if_exp_not_lambda ::= expr jmp_true expr return_if_lambda
|
if_exp_not_lambda ::= expr jmp_true expr return_if_lambda
|
||||||
return_lambda LAMBDA_MARKER
|
return_expr_lambda LAMBDA_MARKER
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
)
|
)
|
||||||
@@ -1452,7 +1452,7 @@ class Python3Parser(PythonParser):
|
|||||||
elif opname == "RETURN_VALUE_LAMBDA":
|
elif opname == "RETURN_VALUE_LAMBDA":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
"""
|
"""
|
||||||
return_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
return_expr_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
)
|
)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2017-2020 Rocky Bernstein
|
# Copyright (c) 2017-2020, 2022 Rocky Bernstein
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -199,10 +199,10 @@ class Python37Parser(Python37BaseParser):
|
|||||||
ret_expr_or_cond ::= ret_expr
|
ret_expr_or_cond ::= ret_expr
|
||||||
ret_expr_or_cond ::= if_exp_ret
|
ret_expr_or_cond ::= if_exp_ret
|
||||||
|
|
||||||
stmt ::= return_lambda
|
stmt ::= return_expr_lambda
|
||||||
|
|
||||||
return_lambda ::= ret_expr RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
return_expr_lambda ::= ret_expr RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||||
return_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
return_expr_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
||||||
|
|
||||||
compare ::= compare_chained
|
compare ::= compare_chained
|
||||||
compare ::= compare_single
|
compare ::= compare_single
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2016-2017, 2019-2020 Rocky Bernstein
|
# Copyright (c) 2016-2017, 2019-2020, 2022 Rocky Bernstein
|
||||||
"""
|
"""
|
||||||
Python 3.7 base code. We keep non-custom-generated grammar rules out of this file.
|
Python 3.7 base code. We keep non-custom-generated grammar rules out of this file.
|
||||||
"""
|
"""
|
||||||
@@ -163,9 +163,9 @@ class Python37BaseParser(PythonParser):
|
|||||||
stmt ::= if_exp_lambda
|
stmt ::= if_exp_lambda
|
||||||
stmt ::= if_exp_not_lambda
|
stmt ::= if_exp_not_lambda
|
||||||
if_exp_lambda ::= expr jmp_false expr return_if_lambda
|
if_exp_lambda ::= expr jmp_false expr return_if_lambda
|
||||||
return_lambda LAMBDA_MARKER
|
return_expr_lambda LAMBDA_MARKER
|
||||||
if_exp_not_lambda ::= expr jmp_true expr return_if_lambda
|
if_exp_not_lambda ::= expr jmp_true expr return_if_lambda
|
||||||
return_lambda LAMBDA_MARKER
|
return_expr_lambda LAMBDA_MARKER
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
)
|
)
|
||||||
@@ -952,7 +952,7 @@ class Python37BaseParser(PythonParser):
|
|||||||
elif opname == "RETURN_VALUE_LAMBDA":
|
elif opname == "RETURN_VALUE_LAMBDA":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
"""
|
"""
|
||||||
return_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
return_expr_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
)
|
)
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
# Copyright (c) 2022 Rocky Bernstein
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from xdis import iscode
|
from xdis import iscode
|
||||||
@@ -46,7 +60,7 @@ def find_all_globals(node, globs):
|
|||||||
# # print("XXX", n.kind, global_ops)
|
# # print("XXX", n.kind, global_ops)
|
||||||
# if isinstance(n, SyntaxTree):
|
# if isinstance(n, SyntaxTree):
|
||||||
# # FIXME: do I need a caser for n.kind="mkfunc"?
|
# # FIXME: do I need a caser for n.kind="mkfunc"?
|
||||||
# if n.kind in ("if_exp_lambda", "return_lambda"):
|
# if n.kind in ("if_exp_lambda", "return_expr_lambda"):
|
||||||
# globs = find_globals(n, globs, lambda_body_globals)
|
# globs = find_globals(n, globs, lambda_body_globals)
|
||||||
# else:
|
# else:
|
||||||
# globs = find_globals(n, globs, global_ops)
|
# globs = find_globals(n, globs, global_ops)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2021 by Rocky Bernstein
|
# Copyright (c) 2015-2022 by Rocky Bernstein
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
# Copyright (c) 1999 John Aycock
|
# Copyright (c) 1999 John Aycock
|
||||||
@@ -491,7 +491,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
|
|
||||||
# Python 3.x can have be dead code as a result of its optimization?
|
# Python 3.x can have be dead code as a result of its optimization?
|
||||||
# So we'll add a # at the end of the return lambda so the rest is ignored
|
# So we'll add a # at the end of the return lambda so the rest is ignored
|
||||||
def n_return_lambda(self, node):
|
def n_return_expr_lambda(self, node):
|
||||||
if 1 <= len(node) <= 2:
|
if 1 <= len(node) <= 2:
|
||||||
self.preorder(node[0])
|
self.preorder(node[0])
|
||||||
self.write(" # Avoid dead code: ")
|
self.write(" # Avoid dead code: ")
|
||||||
|
Reference in New Issue
Block a user