From 1350f4c8999816e52d4d8557de65ea476c0b4cca Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 22 Jun 2018 21:06:54 -0400 Subject: [PATCH] Some bugs... Python 3 compiling Python 2 tolerance. Fixes issue #180. pytest test_grammar.py and validate.py fixes for 3.6 testing --- pytest/test_grammar.py | 8 +++----- pytest/validate.py | 1 + uncompyle6/scanners/scanner2.py | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pytest/test_grammar.py b/pytest/test_grammar.py index 6179e9b1..169eb195 100644 --- a/pytest/test_grammar.py +++ b/pytest/test_grammar.py @@ -46,11 +46,9 @@ def test_grammar(): unused_rhs.add("mkfunc_annotate") unused_rhs.add("dict_comp") unused_rhs.add("classdefdeco1") - if PYTHON_VERSION != 3.6: - if PYTHON_VERSION in (3.5, 3.7): - expect_right_recursive.add((('l_stmts', - ('lastl_stmt', 'come_froms', 'l_stmts')))) - pass + if PYTHON_VERSION in (3.5, 3.6, 3.7): + expect_right_recursive.add((('l_stmts', + ('lastl_stmt', 'come_froms', 'l_stmts')))) pass else: expect_right_recursive.add((('l_stmts', diff --git a/pytest/validate.py b/pytest/validate.py index bbdfa7b5..7a66168b 100644 --- a/pytest/validate.py +++ b/pytest/validate.py @@ -13,6 +13,7 @@ from xdis.bytecode import Bytecode from xdis.main import get_opcode opc = get_opcode(PYTHON_VERSION, IS_PYPY) Bytecode = functools.partial(Bytecode, opc=opc) +import six if PYTHON3: from io import StringIO diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 296beece..77156433 100644 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -43,6 +43,10 @@ from xdis.bytecode import ( _get_const_info) from xdis.util import code2num +from uncompyle6 import PYTHON3 +if PYTHON3: + from sys import intern + from uncompyle6.scanner import Scanner, Token class Scanner2(Scanner):