From 4d5843851543bfb3c97fc3c49036f1a971fc1d66 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 31 Aug 2017 08:53:58 -0400 Subject: [PATCH] Get ready for release 2.11.5 --- ChangeLog | 13 ++++++++- NEWS | 2 +- README.rst | 2 +- __pkginfo__.py | 2 +- uncompyle6/parsers/parse37.py | 41 +++++++++++++++++++++++++++ uncompyle6/semantics/make_function.py | 13 +-------- uncompyle6/version.py | 2 +- 7 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 uncompyle6/parsers/parse37.py diff --git a/ChangeLog b/ChangeLog index ec34f87b..62c6c8c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,17 @@ +2017-08-31 rocky + + * NEWS, README.rst, uncompyle6/parsers/parse37.py, + uncompyle6/semantics/make_function.py, uncompyle6/version.py: Get + ready for release 2.11.5 + 2017-08-15 rocky - * uncompyle6/version.py: Get ready for release 2.11.4 + * Makefile: 3.7 support + +2017-08-15 rocky + + * ChangeLog, NEWS, uncompyle6/version.py: Get ready for release + 2.11.4 2017-08-15 rocky diff --git a/NEWS b/NEWS index efcee88e..d81228c6 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,7 @@ uncompyle6 2.11.4 2017-08-15 * unpin 3.5.1. xdis 3.5.4 has been releasd and fixes the problems we had. Use that. * some routnes here moved to xdis. Use the xdis version * README.rst: Link typo Name is trepan2 now not trepan -* xdis-forched change adjust for COMPARE_OP "is-not" in +* xdis-forced change adjust for COMPARE_OP "is-not" in semanatic routines. We need "is not". * Some PyPy tolerance in validate testing. * Some pyston tolerance diff --git a/README.rst b/README.rst index 90da8d8b..3026c9a1 100644 --- a/README.rst +++ b/README.rst @@ -12,7 +12,7 @@ Introduction *uncompyle6* translates Python bytecode back into equivalent Python source code. It accepts bytecodes from Python version 1.5, and 2.1 to -3.6 or so, including PyPy bytecode and Dropbox's Python 2.5 bytecode. +3.7 or so, including PyPy bytecode and Dropbox's Python 2.5 bytecode. Why this? --------- diff --git a/__pkginfo__.py b/__pkginfo__.py index 04a8b0a4..a6ea6a67 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -40,7 +40,7 @@ entry_points = { ]} ftp_url = None install_requires = ['spark-parser >= 1.6.1, < 1.7.0', - 'xdis >= 3.5.4, < 3.6.0', 'six'] + 'xdis >= 3.5.5, < 3.6.0', 'six'] license = 'MIT' mailing_list = 'python-debugger@googlegroups.com' modname = 'uncompyle6' diff --git a/uncompyle6/parsers/parse37.py b/uncompyle6/parsers/parse37.py new file mode 100644 index 00000000..35f52eac --- /dev/null +++ b/uncompyle6/parsers/parse37.py @@ -0,0 +1,41 @@ +# Copyright (c) 2017 Rocky Bernstein +""" +spark grammar differences over Python 3.6 for Python 3.7 +""" +from __future__ import print_function + +from uncompyle6.parser import PythonParserSingle +from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from uncompyle6.parsers.parse36 import Python37Parser + +class Python36Parser(Python35Parser): + + def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG): + super(Python37Parser, self).__init__(debug_parser) + self.customized = {} + + +class Python37ParserSingle(Python37Parser, PythonParserSingle): + pass + +if __name__ == '__main__': + # Check grammar + p = Python37Parser() + p.checkGrammar() + from uncompyle6 import PYTHON_VERSION, IS_PYPY + if PYTHON_VERSION == 3.7: + lhs, rhs, tokens, right_recursive = p.checkSets() + from uncompyle6.scanner import get_scanner + s = get_scanner(PYTHON_VERSION, IS_PYPY) + opcode_set = set(s.opc.opname).union(set( + """JUMP_BACK CONTINUE RETURN_END_IF COME_FROM + LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME + LAMBDA_MARKER RETURN_LAST + """.split())) + remain_tokens = set(tokens) - opcode_set + import re + remain_tokens = set([re.sub('_\d+$', '', t) for t in remain_tokens]) + remain_tokens = set([re.sub('_CONT$', '', t) for t in remain_tokens]) + remain_tokens = set(remain_tokens) - opcode_set + print(remain_tokens) + # print(sorted(p.rule2name.items())) diff --git a/uncompyle6/semantics/make_function.py b/uncompyle6/semantics/make_function.py index be670950..0b0efaf1 100644 --- a/uncompyle6/semantics/make_function.py +++ b/uncompyle6/semantics/make_function.py @@ -3,7 +3,7 @@ """ All the crazy things we have to do to handle Python functions """ -from xdis.code import iscode +from xdis.code import iscode, code_has_star_arg, code_has_star_star_arg from uncompyle6.scanner import Code from uncompyle6.parsers.astnode import AST from uncompyle6 import PYTHON3 @@ -45,17 +45,6 @@ def find_none(node): return True return False -# FIXME: put this in xdis -def code_has_star_arg(code): - """Return True iff - the code object has a variable positional parameter (*args-like)""" - return (code.co_flags & 4) != 0 - -def code_has_star_star_arg(code): - """Return True iff - The code object has a variable keyword parameter (**kwargs-like).""" - return (code.co_flags & 8) != 0 - # FIXME: DRY the below code... def make_function3_annotate(self, node, isLambda, nested=1, diff --git a/uncompyle6/version.py b/uncompyle6/version.py index e7a1612b..5d5aeedc 100644 --- a/uncompyle6/version.py +++ b/uncompyle6/version.py @@ -1,3 +1,3 @@ # This file is suitable for sourcing inside bash as # well as importing into Python -VERSION='2.11.4' +VERSION='2.11.5'