From 8d084ed3585607cc58a3f891b49034d916c0e2e8 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 8 May 2017 06:58:12 -0400 Subject: [PATCH] pysource guard and another appveyor test --- appveyor.yml | 2 +- test/test_pyenvlib.py | 9 +++++++-- uncompyle6/semantics/pysource.py | 11 ++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 47cab67d..04ac8d77 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -61,7 +61,7 @@ build_script: test_script: # Run the project tests - - "%CMD_IN_ENV% python test/test_pythonlib.py --2.7 --verify" + - "%CMD_IN_ENV% python test/test_pyenvlib.py --native --weak-verify" after_test: # If tests are successful, create binary packages for the project. diff --git a/test/test_pyenvlib.py b/test/test_pyenvlib.py index a9bb408a..2cacdd4c 100755 --- a/test/test_pyenvlib.py +++ b/test/test_pyenvlib.py @@ -22,7 +22,7 @@ Step 2: Run the test: from __future__ import print_function from uncompyle6 import main, PYTHON3 -import os, time, shutil +import os, time, shutil, sys from fnmatch import fnmatch #----- configure this for your needs @@ -33,7 +33,7 @@ TEST_VERSIONS=('2.3.7', '2.4.6', '2.5.6', '2.6.9', '2.7.10', '2.7.11', '2.7.12', '2.7.13', '3.0.1', '3.1.5', '3.2.6', '3.3.5', '3.3.6', - '3.4.2', '3.5.1', '3.6.0') + '3.4.2', '3.5.1', '3.6.0', 'native') target_base = '/tmp/py-dis/' lib_prefix = os.path.join(os.environ['HOME'], '.pyenv/versions') @@ -54,6 +54,11 @@ for vers in TEST_VERSIONS: short_vers = vers[0:-2] test_options[vers] = (os.path.join(lib_prefix, vers, 'lib_pypy'), PYC, 'python-lib'+short_vers) + if vers == 'native': + short_vers = os.path.basename(sys.path[-1]) + test_options[vers] = (sys.path[-1], + PYC, short_vers) + else: short_vers = vers[:3] test_options[vers] = (os.path.join(lib_prefix, vers, 'lib', 'python'+short_vers), diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index a0d1fd13..e4d8666e 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -531,11 +531,12 @@ class SourceWalker(GenericASTTraversal, object): next_offset = self.scanner.next_offset(op, offset) scanner = self.scanner code = scanner.code - next_inst = code[next_offset] - if (scanner.opc.opname[next_inst] == 'JUMP_ABSOLUTE' - and t.pattr == code[next_offset+1]): - # Suppress "continue" - self.prune() + if next_offset < len(code): + next_inst = code[next_offset] + if (scanner.opc.opname[next_inst] == 'JUMP_ABSOLUTE' + and t.pattr == code[next_offset+1]): + # Suppress "continue" + self.prune() self.default(node) def n_return_stmt(self, node):