diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 23b5c206..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,11 +0,0 @@ -default_language_version: - python: python -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: check-merge-conflict - - id: debug-statements - stages: [commit] - - id: end-of-file-fixer - stages: [commit] diff --git a/admin-tools/merge-for-3.6.sh b/admin-tools/merge-for-3.6.sh index 7915bda3..82c74335 100755 --- a/admin-tools/merge-for-3.6.sh +++ b/admin-tools/merge-for-3.6.sh @@ -1,7 +1,7 @@ #/bin/bash -uncompyle6_merge_33_owd=$(pwd) +uncompyle6_merge_36_owd=$(pwd) cd $(dirname ${BASH_SOURCE[0]}) -if . ./setup-python-3.3.sh; then +if . ./setup-python-3.6.sh; then git merge master fi -cd $uncompyle6_merge_33_owd +cd $uncompyle6_merge_36_owd diff --git a/admin-tools/setup-python-2.4.sh b/admin-tools/setup-python-2.4.sh index 843cf285..71e4ee04 100644 --- a/admin-tools/setup-python-2.4.sh +++ b/admin-tools/setup-python-2.4.sh @@ -17,7 +17,7 @@ cd $mydir (cd $fulldir/.. && \ setup_version python-spark python-2.4 && \ - setup_verseion python-xdis python-2.4-to-2.7) + setup_version python-xdis python-2.4-to-2.7) checkout_finish python-2.4-to-2.7 diff --git a/test/bytecode_2.7/06_nop.pyc b/test/bytecode_2.7/06_nop.pyc new file mode 100644 index 00000000..0f6f966d Binary files /dev/null and b/test/bytecode_2.7/06_nop.pyc differ diff --git a/test/bytecode_3.6/06_nop.pyc b/test/bytecode_3.6/06_nop.pyc new file mode 100644 index 00000000..f0420f2b Binary files /dev/null and b/test/bytecode_3.6/06_nop.pyc differ diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 017bba22..92fc2ada 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -385,6 +385,10 @@ class PythonParser(GenericASTBuilder): returns ::= return returns ::= _stmts return + + # NOP + stmt ::= nop_stmt + nop_stmt ::= NOP """ pass diff --git a/uncompyle6/semantics/customize37.py b/uncompyle6/semantics/customize37.py index 7e5193fa..48701243 100644 --- a/uncompyle6/semantics/customize37.py +++ b/uncompyle6/semantics/customize37.py @@ -17,7 +17,7 @@ import re -from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE, TABLE_DIRECT +from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE from uncompyle6.semantics.helper import flatten_list # FIXME get from a newer xdis diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index bd52f69d..c886e2b8 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -86,14 +86,13 @@ else: from uncompyle6.semantics.consts import ( INDENT_PER_LEVEL, - MAP, NONE, PASS, PRECEDENCE, TABLE_DIRECT, - TABLE_R, escape, ) +from uncompyle6.semantics.helper import find_code_node from uncompyle6.semantics.pysource import ( DEFAULT_DEBUG_OPTS, TREE_DEFAULT_DEBUG, @@ -607,17 +606,7 @@ class FragmentsWalker(pysource.SourceWalker, object): def n_mkfunc(self, node): start = len(self.f.getvalue()) - if self.version >= (3, 3) or node[-2] == "kwargs": - # LOAD_CONST code object .. - # LOAD_CONST 'x0' if >= 3.3 - # MAKE_FUNCTION .. - code_node = node[-3] - elif node[-2] == "expr": - code_node = node[-2][0] - else: - # LOAD_CONST code object .. - # MAKE_FUNCTION .. - code_node = node[-2] + code_node = find_code_node(node, -2) func_name = code_node.attr.co_name self.write(func_name) self.set_pos_info(code_node, start, len(self.f.getvalue())) diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 7080ff0e..b198154a 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1259,11 +1259,20 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin): if tokens[-1].kind in ("RETURN_VALUE", "RETURN_VALUE_LAMBDA"): # Python 3.4's classes can add a "return None" which is # invalid syntax. - if tokens[-2].kind == "LOAD_CONST": - if is_top_level_module or tokens[-2].pattr is None: - del tokens[-2:] - else: - tokens.append(Token("RETURN_LAST")) + load_const = tokens[-2] + # We should have: + # LOAD_CONST None + # with *no* line number associated the token. + # A line number on the token or a non-None + # token value a token based on user source + # text. + if ( + load_const.kind == "LOAD_CONST" + and load_const.linestart is None + and load_const.attr is None + ): + # Delete LOAD_CONST (None) RETURN_VALUE + del tokens[-2:] else: tokens.append(Token("RETURN_LAST")) if len(tokens) == 0: @@ -1369,6 +1378,7 @@ def code_deparse( co, is_lambda=is_lambda_mode(compile_mode), is_top_level_module=is_top_level_module, + compile_mode=compile_mode, ) # XXX workaround for profiling