diff --git a/NEWS b/NEWS index d81228c6..25859e85 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,14 @@ +uncompyle6 2.12.0 2017-09-25 + +- Use xdis 3.6.0 or greater now +- Small semantic table cleanups +- Python 3.4's terms a little names better +- Slightly more Python 3.7, but still failing a lot + +uncompyle6 2.11.5 2017-08-31 + +- Skeletal support for Python 3.7 + uncompyle6 2.11.4 2017-08-15 * scanner and parser now allow 3-part version string lookups, diff --git a/pytest/test_pysource.py b/pytest/test_pysource.py index aacefdf3..d7f4e776 100644 --- a/pytest/test_pysource.py +++ b/pytest/test_pysource.py @@ -1,6 +1,6 @@ from uncompyle6 import PYTHON3 from uncompyle6.semantics.consts import ( - NONE, + escape, NONE, # RETURN_NONE, PASS, RETURN_LOCALS ) @@ -18,3 +18,143 @@ def test_template_engine(): sw.template_engine(('--%c--', 0), NONE) print(sw.f.getvalue()) assert sw.f.getvalue() == '--None--' + # FIXME: and so on... + +from uncompyle6.semantics.consts import ( + TABLE_R, TABLE_DIRECT, + ) + +from uncompyle6.semantics.fragments import ( + TABLE_DIRECT_FRAGMENT, + ) + +def test_tables(): + for t, name, fragment in ( + (TABLE_DIRECT, 'TABLE_DIRECT', False), + (TABLE_R, 'TABLE_R', False), + (TABLE_DIRECT_FRAGMENT, 'TABLE_DIRECT_FRAGMENT', True)): + for k, entry in t.iteritems(): + fmt = entry[0] + arg = 1 + i = 0 + m = escape.search(fmt) + print("%s[%s]" % (name, k)) + while m: + i = m.end() + typ = m.group('type') or '{' + if typ in frozenset(['%', '+', '-', '|', ',', '{']): + # No args + pass + elif typ in frozenset(['c', 'p', 'P', 'C', 'D']): + # One arg - should be int or tuple of int + if typ == 'c': + assert isinstance(entry[arg], int), ( + "%s[%s][%d] type %s is '%s' should be an int but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + elif typ in frozenset(['C', 'D']): + tup = entry[arg] + assert isinstance(tup, tuple), ( + "%s[%s][%d] type %s is %s should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + assert len(tup) == 3 + for j, x in enumerate(tup[:-1]): + assert isinstance(x, int), ( + "%s[%s][%d][%d] type %s is %s should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, j, typ, x, type(x), entry) + ) + assert isinstance(tup[-1], str) or tup[-1] is None, ( + "%s[%s][%d][%d] sep type %s is %s should be an string but is %s. " + "Full entry: %s" % + (name, k, arg, j, typ, tup[-1], type(x), entry) + ) + + elif typ == 'P': + tup = entry[arg] + assert isinstance(tup, tuple), ( + "%s[%s][%d] type %s is %s should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + assert len(tup) == 4 + for j, x in enumerate(tup[:-2]): + assert isinstance(x, int), ( + "%s[%s][%d][%d] type %s is '%s' should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, j, typ, x, type(x), entry) + ) + assert isinstance(tup[-2], str), ( + "%s[%s][%d][%d] sep type %s is '%s' should be an string but is %s. " + "Full entry: %s" % + (name, k, arg, j, typ, x, type(x), entry) + ) + assert isinstance(tup[1], int), ( + "%s[%s][%d][%d] prec type %s is '%s' should be an int but is %s. " + "Full entry: %s" % + (name, k, arg, j, typ, x, type(x), entry) + ) + + else: + # Should be a tuple which contains only ints + tup = entry[arg] + assert isinstance(tup, tuple), ( + "%s[%s][%d] type %s is '%s' should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + assert len(tup) == 2 + for j, x in enumerate(tup): + assert isinstance(x, int), ( + "%s[%s][%d][%d] type '%s' is '%s should be an int but is %s. Full entry: %s" % + (name, k, arg, j, typ, x, type(x), entry) + ) + pass + arg += 1 + elif typ in frozenset(['r']) and fragment: + pass + elif typ == 'b' and fragment: + assert isinstance(entry[arg], int), ( + "%s[%s][%d] type %s is '%s' should be an int but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + arg += 1 + elif typ == 'x' and fragment: + tup = entry[arg] + assert isinstance(tup, tuple), ( + "%s[%s][%d] type %s is '%s' should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + assert len(tup) == 2 + assert isinstance(tup[0], int), ( + "%s[%s][%d] source type %s is '%s' should be an int but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + assert isinstance(tup[1], tuple), ( + "%s[%s][%d] dest type %s is '%s' should be an tuple but is %s. " + "Full entry: %s" % + (name, k, arg, typ, entry[arg], type(entry[arg]), entry) + ) + for j, x in enumerate(tup[1]): + assert isinstance(x, int), ( + "%s[%s][%d][%d] type %s is %s should be an int but is %s. Full entry: %s" % + (name, k, arg, j, typ, x, type(x), entry) + ) + arg += 1 + pass + else: + assert False, ( + "%s[%s][%d] type %s is not known. Full entry: %s" % + (name, k, arg, typ, entry) + ) + m = escape.search(fmt, i) + pass + assert arg == len(entry), ( + "%s[%s] arg %d should be length of entry %d. Full entry: %s" % + (name, k, arg, len(entry), entry)) diff --git a/uncompyle6/scanner.py b/uncompyle6/scanner.py index 750c565c..a92ae837 100755 --- a/uncompyle6/scanner.py +++ b/uncompyle6/scanner.py @@ -54,7 +54,7 @@ class Scanner(object): if version in PYTHON_VERSIONS: if is_pypy: - v_str = "opcode_pypy%s" % (int(version * 10)) + v_str = "opcode_%spypy" % (int(version * 10)) else: v_str = "opcode_%s" % (int(version * 10)) exec("from xdis.opcodes import %s" % v_str) @@ -63,6 +63,7 @@ class Scanner(object): raise TypeError("%s is not a Python version I know about" % version) self.opname = self.opc.opname + # FIXME: This weird Python2 behavior is not Python3 self.resetTokenClass() @@ -99,7 +100,7 @@ class Scanner(object): def print_bytecode(self): for i in self.op_range(0, len(self.code)): op = self.code[i] - if op in self.JUMP_OPs: + if op in self.JUMP_OPS: dest = self.get_target(i, op) print('%i\t%s\t%i' % (i, self.opname[op], dest)) else: diff --git a/uncompyle6/scanners/pypy27.py b/uncompyle6/scanners/pypy27.py index 4ecfd628..ed32de87 100644 --- a/uncompyle6/scanners/pypy27.py +++ b/uncompyle6/scanners/pypy27.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ Python PyPy 2.7 bytecode scanner/deparser @@ -10,8 +10,8 @@ information for later use in deparsing. import uncompyle6.scanners.scanner27 as scan # bytecode verification, verify(), uses JUMP_OPs from here -from xdis.opcodes import opcode_pypy27 -JUMP_OPs = opcode_pypy27.JUMP_OPs +from xdis.opcodes import opcode_27pypy +JUMP_OPS = opcode_27pypy.JUMP_OPS # We base this off of 2.6 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/pypy35.py b/uncompyle6/scanners/pypy35.py index a2c660a9..2cbca409 100644 --- a/uncompyle6/scanners/pypy35.py +++ b/uncompyle6/scanners/pypy35.py @@ -8,9 +8,9 @@ make things easier for decompilation. import uncompyle6.scanners.scanner35 as scan -# bytecode verification, verify(), uses JUMP_OPs from here +# bytecode verification, verify(), uses JUMP_OPS from here from xdis.opcodes import opcode_35 as opc # is this right? -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPs = opc.JUMP_OPS # We base this off of 3.5 class ScannerPyPy35(scan.Scanner35): diff --git a/uncompyle6/scanners/scanner15.py b/uncompyle6/scanners/scanner15.py index 21d86bda..867e64f0 100644 --- a/uncompyle6/scanners/scanner15.py +++ b/uncompyle6/scanners/scanner15.py @@ -11,7 +11,7 @@ import uncompyle6.scanners.scanner21 as scan # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_15 -JUMP_OPs = opcode_15.JUMP_OPs +JUMP_OPS = opcode_15.JUMP_OPS # We base this off of 2.1 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/scanner21.py b/uncompyle6/scanners/scanner21.py index 53a5b405..271c52db 100644 --- a/uncompyle6/scanners/scanner21.py +++ b/uncompyle6/scanners/scanner21.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ Python 2.1 bytecode scanner/deparser @@ -11,7 +11,7 @@ import uncompyle6.scanners.scanner22 as scan # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_21 -JUMP_OPs = opcode_21.JUMP_OPs +JUMP_OPS = opcode_21.JUMP_OPS # We base this off of 2.2 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/scanner22.py b/uncompyle6/scanners/scanner22.py index d2f8eecd..c3effbc2 100644 --- a/uncompyle6/scanners/scanner22.py +++ b/uncompyle6/scanners/scanner22.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ Python 2.2 bytecode ingester. @@ -11,7 +11,7 @@ import uncompyle6.scanners.scanner23 as scan # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_22 -JUMP_OPs = opcode_22.JUMP_OPs +JUMP_OPS = opcode_22.JUMP_OPS # We base this off of 2.3 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/scanner23.py b/uncompyle6/scanners/scanner23.py index 688fa1b6..9919b831 100644 --- a/uncompyle6/scanners/scanner23.py +++ b/uncompyle6/scanners/scanner23.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ Python 2.3 bytecode scanner/deparser @@ -10,7 +10,7 @@ import uncompyle6.scanners.scanner24 as scan # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_23 -JUMP_OPs = opcode_23.JUMP_OPs +JUMP_OPS = opcode_23.JUMP_OPS # We base this off of 2.4 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/scanner24.py b/uncompyle6/scanners/scanner24.py index b994241e..b7ae220b 100755 --- a/uncompyle6/scanners/scanner24.py +++ b/uncompyle6/scanners/scanner24.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ Python 2.4 bytecode scanner/deparser @@ -10,7 +10,7 @@ import uncompyle6.scanners.scanner25 as scan # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_24 -JUMP_OPs = opcode_24.JUMP_OPs +JUMP_OPS = opcode_24.JUMP_OPS # We base this off of 2.5 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/scanner25.py b/uncompyle6/scanners/scanner25.py index c270d003..3162388d 100755 --- a/uncompyle6/scanners/scanner25.py +++ b/uncompyle6/scanners/scanner25.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016 by Rocky Bernstein +# Copyright (c) 2015-2017 by Rocky Bernstein """ Python 2.5 bytecode scanner/deparser @@ -11,7 +11,7 @@ import uncompyle6.scanners.scanner26 as scan # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_25 -JUMP_OPs = opcode_25.JUMP_OPs +JUMP_OPS = opcode_25.JUMP_OPS # We base this off of 2.6 instead of the other way around # because we cleaned things up this way. diff --git a/uncompyle6/scanners/scanner26.py b/uncompyle6/scanners/scanner26.py index efe00747..c7297343 100755 --- a/uncompyle6/scanners/scanner26.py +++ b/uncompyle6/scanners/scanner26.py @@ -19,7 +19,7 @@ from uncompyle6.scanner import L65536 # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_26 -JUMP_OPs = opcode_26.JUMP_OPs +JUMP_OPS = opcode_26.JUMP_OPS class Scanner26(scan.Scanner2): def __init__(self, show_asm=False): diff --git a/uncompyle6/scanners/scanner27.py b/uncompyle6/scanners/scanner27.py index 024253fc..7046865a 100755 --- a/uncompyle6/scanners/scanner27.py +++ b/uncompyle6/scanners/scanner27.py @@ -16,7 +16,7 @@ if PYTHON3: # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_27 -JUMP_OPs = opcode_27.JUMP_OPs +JUMP_OPS = opcode_27.JUMP_OPs class Scanner27(Scanner2): def __init__(self, show_asm=False, is_pypy=False): diff --git a/uncompyle6/scanners/scanner30.py b/uncompyle6/scanners/scanner30.py index de0976e5..0b4b7ce3 100644 --- a/uncompyle6/scanners/scanner30.py +++ b/uncompyle6/scanners/scanner30.py @@ -10,7 +10,7 @@ scanner routine for Python 3. from xdis.opcodes import opcode_30 as opc from xdis.bytecode import op_size -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS JUMP_TF = frozenset([opc.JUMP_IF_FALSE, opc.JUMP_IF_TRUE]) diff --git a/uncompyle6/scanners/scanner31.py b/uncompyle6/scanners/scanner31.py index 15f56918..95196222 100644 --- a/uncompyle6/scanners/scanner31.py +++ b/uncompyle6/scanners/scanner31.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ Python 3.1 bytecode scanner/deparser @@ -8,7 +8,7 @@ scanner routine for Python 3. # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_31 as opc -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS from uncompyle6.scanners.scanner3 import Scanner3 class Scanner31(Scanner3): diff --git a/uncompyle6/scanners/scanner32.py b/uncompyle6/scanners/scanner32.py index b1b2fed8..07a1a28c 100644 --- a/uncompyle6/scanners/scanner32.py +++ b/uncompyle6/scanners/scanner32.py @@ -11,7 +11,7 @@ scanner routine for Python 3. # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_32 as opc -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS from uncompyle6.scanners.scanner3 import Scanner3 class Scanner32(Scanner3): diff --git a/uncompyle6/scanners/scanner33.py b/uncompyle6/scanners/scanner33.py index 06268003..5e99f855 100644 --- a/uncompyle6/scanners/scanner33.py +++ b/uncompyle6/scanners/scanner33.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016 by Rocky Bernstein +# Copyright (c) 2015-2017 by Rocky Bernstein """ Python 3.3 bytecode scanner/deparser @@ -8,7 +8,7 @@ scanner routine for Python 3. # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_33 as opc -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS from uncompyle6.scanners.scanner3 import Scanner3 class Scanner33(Scanner3): diff --git a/uncompyle6/scanners/scanner34.py b/uncompyle6/scanners/scanner34.py index 80d14842..e9de0659 100644 --- a/uncompyle6/scanners/scanner34.py +++ b/uncompyle6/scanners/scanner34.py @@ -12,7 +12,7 @@ scanner routine for Python 3. from xdis.opcodes import opcode_34 as opc # bytecode verification, verify(), uses JUMP_OPs from here -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS from uncompyle6.scanners.scanner3 import Scanner3 diff --git a/uncompyle6/scanners/scanner35.py b/uncompyle6/scanners/scanner35.py index 2d9265fa..370c56e1 100644 --- a/uncompyle6/scanners/scanner35.py +++ b/uncompyle6/scanners/scanner35.py @@ -13,7 +13,7 @@ from uncompyle6.scanners.scanner3 import Scanner3 # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_35 as opc -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS class Scanner35(Scanner3): diff --git a/uncompyle6/scanners/scanner36.py b/uncompyle6/scanners/scanner36.py index dd293d4f..a9d5bd01 100644 --- a/uncompyle6/scanners/scanner36.py +++ b/uncompyle6/scanners/scanner36.py @@ -11,9 +11,9 @@ scanner routine for Python 3. from uncompyle6.scanners.scanner3 import Scanner3 -# bytecode verification, verify(), uses JUMP_OPs from here +# bytecode verification, verify(), uses JUMP_OPS from here from xdis.opcodes import opcode_36 as opc -JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) +JUMP_OPS = opc.JUMP_OPS class Scanner36(Scanner3): diff --git a/uncompyle6/scanners/scanner37.py b/uncompyle6/scanners/scanner37.py new file mode 100644 index 00000000..0e22ba60 --- /dev/null +++ b/uncompyle6/scanners/scanner37.py @@ -0,0 +1,38 @@ +# Copyright (c) 2016-2017 by Rocky Bernstein +""" +Python 3.7 bytecode decompiler scanner + +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. + +This sets up opcodes Python's 3.6 and calls a generalized +scanner routine for Python 3. +""" + +from __future__ import print_function + +from uncompyle6.scanners.scanner3 import Scanner3 + +# bytecode verification, verify(), uses JUMP_OPs from here +from xdis.opcodes import opcode_36 as opc +JUMP_OPs = opc.JUMP_OPS + +class Scanner37(Scanner3): + + def __init__(self, show_asm=None): + Scanner3.__init__(self, 3.7, show_asm) + return + pass + +if __name__ == "__main__": + from uncompyle6 import PYTHON_VERSION + if PYTHON_VERSION == 3.7: + import inspect + co = inspect.currentframe().f_code + tokens, customize = Scanner37().ingest(co) + for t in tokens: + print(t.format()) + pass + else: + print("Need to be Python 3.7 to demo; I am %s." % + PYTHON_VERSION) diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index a2194595..b5d49644 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -99,7 +99,7 @@ TABLE_DIRECT = { 'UNARY_POSITIVE': ( '+',), 'UNARY_NEGATIVE': ( '-',), - 'UNARY_INVERT': ( '~%c'), + 'UNARY_INVERT': ( '~'), 'unary_expr': ( '%c%c', 1, 0), 'unary_not': ( 'not %c', 0 ), diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index c2da61b4..5fc880e4 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -40,7 +40,8 @@ do it recursively which is where offsets are probably located. 2. %b ----- - %b associates the text from the previous start node up to what we have now + %b associates the text from the specified index to what we have now. + it takes an integer argument. For example in: 'importmultiple': ( '%|import%b %c%c\n', 0, 2, 3 ), @@ -98,7 +99,7 @@ TABLE_DIRECT_FRAGMENT = { 'list_for': (' for %c%x in %c%c', 2, (2, (1, )), 0, 3 ), 'forstmt': ( '%|for%b %c%x in %c:\n%+%c%-\n\n', 0, 3, (3, (2, )), 1, 4 ), 'forelsestmt': ( - '%|for %c in %c%x:\n%+%c%-%|else:\n%+%c%-\n\n', 3, (3, (2,)), 1, 4, -2), + '%|for %c%x in %c:\n%+%c%-%|else:\n%+%c%-\n\n', 3, (3, (2,)), 1, 4, -2), 'forelselaststmt': ( '%|for %c%x in %c:\n%+%c%-%|else:\n%+%c%-', 3, (3, (2,)), 1, 4, -2), 'forelselaststmtl': ( diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 3b21ff7c..61aff590 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -61,18 +61,22 @@ Python. # index and the precidence value, an integer. # # %C evaluate children recursively, with sibling children separated by the -# given string. It needs a tuple of 3 items, a starting node, the maximimum +# given string. It needs a 3-tuple: a starting node, the maximimum # value of an end node, and a string to be inserted between sibling children # # %, Append ',' if last %C only printed one item. This is mostly for tuples # on the LHS of an assignment statement since BUILD_TUPLE_n pretty-prints # other tuples. The specifier takes no arguments # -# %P same as %C but sets operator precedence. +# %P same as %C but sets operator precedence. Its argument is a 4-tuple: +# the node low and high indices, the separator, a string the precidence +# value, an integer. # -# %D Same as `%C` this is for left-recursive lists like kwargs where -# goes to epsilon at the beginning. If we were to use `%C` an extra separator -# with an epsilon would appear at the beginning. +# %D Same as `%C` this is for left-recursive lists like kwargs where goes +# to epsilon at the beginning. It needs a 3-tuple: a starting node, the +# maximimum value of an end node, and a string to be inserted between +# sibling children. If we were to use `%C` an extra separator with an +# epsilon would appear at the beginning. # # %| Insert spaces to the current indentation level. Takes no arguments. # @@ -1940,7 +1944,7 @@ class SourceWalker(GenericASTTraversal, object): 'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'): if v == 0: str = '%c(%C' # '%C' is a dummy here ... - p2 = (0, 0, None) # .. because of this + p2 = (0, 0, None) # .. because of the None in this else: str = '%c(%C, ' p2 = (1, -2, ', ') diff --git a/uncompyle6/verify.py b/uncompyle6/verify.py index cdafcdf1..a353c8e2 100755 --- a/uncompyle6/verify.py +++ b/uncompyle6/verify.py @@ -43,7 +43,7 @@ BIN_OP_FUNCS = { 'BINARY_OR': operator.or_, } -JUMP_OPs = None +JUMP_OPS = None # --- exceptions --- @@ -225,8 +225,8 @@ def cmp_code_objects(version, is_pypy, code_obj1, code_obj2, import uncompyle6.scanners.scanner36 as scan scanner = scan.Scanner36() - global JUMP_OPs - JUMP_OPs = list(scan.JUMP_OPs) + ['JUMP_BACK'] + global JUMP_OPS + JUMP_OPS = list(scan.JUMP_OPS) + ['JUMP_BACK'] # use changed Token class # We (re)set this here to save exception handling, @@ -331,7 +331,7 @@ def cmp_code_objects(version, is_pypy, code_obj1, code_obj2, else: raise CmpErrorCode(name, tokens1[i1].offset, tokens1[i1], tokens2[i2], tokens1, tokens2) - elif tokens1[i1].type in JUMP_OPs and tokens1[i1].pattr != tokens2[i2].pattr: + elif tokens1[i1].type in JUMP_OPS and tokens1[i1].pattr != tokens2[i2].pattr: if tokens1[i1].type == 'JUMP_BACK': dest1 = int(tokens1[i1].pattr) dest2 = int(tokens2[i2].pattr) @@ -398,7 +398,7 @@ class Token(scanner.Token): return 0 if t == 'JUMP_IF_FALSE_OR_POP' and o.type == 'POP_JUMP_IF_FALSE': return 0 - if JUMP_OPs and t in JUMP_OPs: + if JUMP_OPS and t in JUMP_OPS: # ignore offset return t == o.type return (t == o.type) or self.pattr == o.pattr diff --git a/uncompyle6/version.py b/uncompyle6/version.py index 5d5aeedc..f6cb5567 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.5' +VERSION='2.12.0'