diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index f2af9b98..ab035d61 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -653,10 +653,10 @@ class Python2Parser(PythonParser): pass self.reduce_check_table = { - # "and": and_check, + # "and": and_invalid, "except_handler_else": except_handler_else, "ifelsestmt": ifelsestmt, - # "or": or_check, + # "or": or_invalid, "tryelsestmt": tryelsestmt, "tryelsestmtl": tryelsestmt, } diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 64afd030..80bcc874 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -30,7 +30,7 @@ import re from uncompyle6.scanners.tok import Token from uncompyle6.parser import PythonParser, PythonParserSingle, nop_func from uncompyle6.parsers.reducecheck import ( - and_check, + and_invalid, except_handler_else, ifelsestmt, ifstmt, @@ -1581,7 +1581,7 @@ class Python3Parser(PythonParser): } if self.version == (3, 6): - self.reduce_check_table["and"] = and_check + self.reduce_check_table["and"] = and_invalid self.check_reduce["and"] = "AST" self.check_reduce["annotate_tuple"] = "noAST" diff --git a/uncompyle6/parsers/parse37base.py b/uncompyle6/parsers/parse37base.py index 3643fae7..ef307cc5 100644 --- a/uncompyle6/parsers/parse37base.py +++ b/uncompyle6/parsers/parse37base.py @@ -8,7 +8,7 @@ from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG from spark_parser.spark import rule2str from uncompyle6.parsers.reducecheck import ( - and_check, + and_invalid, ifelsestmt, iflaststmt, ifstmt, @@ -1128,7 +1128,7 @@ class Python37BaseParser(PythonParser): self.reduce_check_table = { "_ifstmts_jump": ifstmts_jump, - "and": and_check, + "and": and_invalid, "ifelsestmt": ifelsestmt, "ifelsestmtl": ifelsestmt, "iflaststmt": iflaststmt, diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index 3c7789d7..69c2f4c6 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -20,7 +20,6 @@ from __future__ import print_function from uncompyle6.parser import PythonParserSingle, nop_func from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG from uncompyle6.parsers.parse37 import Python37Parser -from uncompyle6.parsers.reducecheck import joined_str_check class Python38Parser(Python37Parser): def p_38_stmt(self, args): diff --git a/uncompyle6/parsers/reducecheck/__init__.py b/uncompyle6/parsers/reducecheck/__init__.py index 4820b6cf..4f99ab2f 100644 --- a/uncompyle6/parsers/reducecheck/__init__.py +++ b/uncompyle6/parsers/reducecheck/__init__.py @@ -1,18 +1,18 @@ -from uncompyle6.parsers.reducecheck.and_check import * -from uncompyle6.parsers.reducecheck.aug_assign import * -from uncompyle6.parsers.reducecheck.except_handler import * -from uncompyle6.parsers.reducecheck.except_handler_else import * -from uncompyle6.parsers.reducecheck.ifelsestmt import * -from uncompyle6.parsers.reducecheck.ifelsestmt2 import * -from uncompyle6.parsers.reducecheck.iflaststmt import * -from uncompyle6.parsers.reducecheck.ifstmt import * -from uncompyle6.parsers.reducecheck.ifstmt2 import * -from uncompyle6.parsers.reducecheck.ifstmts_jump import * -from uncompyle6.parsers.reducecheck.for_block_check import * -from uncompyle6.parsers.reducecheck.or_check import * -from uncompyle6.parsers.reducecheck.testtrue import * -from uncompyle6.parsers.reducecheck.tryelsestmt import * -from uncompyle6.parsers.reducecheck.tryexcept import * -from uncompyle6.parsers.reducecheck.tryelsestmtl3 import * -from uncompyle6.parsers.reducecheck.while1elsestmt import * -from uncompyle6.parsers.reducecheck.while1stmt import * +from uncompyle6.parsers.reducecheck.and_check import * # noqa +from uncompyle6.parsers.reducecheck.aug_assign import * # noqa +from uncompyle6.parsers.reducecheck.except_handler import * # noqa +from uncompyle6.parsers.reducecheck.except_handler_else import * # noqa +from uncompyle6.parsers.reducecheck.ifelsestmt import * # noqa +from uncompyle6.parsers.reducecheck.ifelsestmt2 import * # noqa +from uncompyle6.parsers.reducecheck.iflaststmt import * # noqa +from uncompyle6.parsers.reducecheck.ifstmt import * # noqa +from uncompyle6.parsers.reducecheck.ifstmt2 import * # noqa +from uncompyle6.parsers.reducecheck.ifstmts_jump import * # noqa +from uncompyle6.parsers.reducecheck.for_block_check import * # noqa +from uncompyle6.parsers.reducecheck.or_check import * # noqa +from uncompyle6.parsers.reducecheck.testtrue import * # noqa +from uncompyle6.parsers.reducecheck.tryelsestmt import * # noqa +from uncompyle6.parsers.reducecheck.tryexcept import * # noqa +from uncompyle6.parsers.reducecheck.tryelsestmtl3 import * # noqa +from uncompyle6.parsers.reducecheck.while1elsestmt import * # noqa +from uncompyle6.parsers.reducecheck.while1stmt import * # noqa diff --git a/uncompyle6/parsers/reducecheck/and_check.py b/uncompyle6/parsers/reducecheck/and_check.py index 5e590821..afffbcb3 100644 --- a/uncompyle6/parsers/reducecheck/and_check.py +++ b/uncompyle6/parsers/reducecheck/and_check.py @@ -1,7 +1,13 @@ -# Copyright (c) 2020 Rocky Bernstein +# Copyright (c) 2020, 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 -def and_check(self, lhs, n, rule, ast, tokens, first, last): + +def and_invalid( + self, lhs: str, n: int, rule, ast, tokens: list, first: int, last: int + ) -> bool: jmp = ast[1] if jmp.kind.startswith("jmp_"): if last == n: diff --git a/uncompyle6/parsers/reducecheck/joined_str_check.py b/uncompyle6/parsers/reducecheck/joined_str_check.py index 96ddc7b9..c6f67441 100644 --- a/uncompyle6/parsers/reducecheck/joined_str_check.py +++ b/uncompyle6/parsers/reducecheck/joined_str_check.py @@ -13,7 +13,7 @@ # along with this program. If not, see . -def joined_str_ok( +def joined_str_invalid( self, lhs: str, n: int, rule, tree, tokens: list, first: int, last: int ) -> bool: # In Python 3.8, there is a new "=" specifier.