diff --git a/NEWS.md b/NEWS.md index e6b42db5..d21dc151 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +5.0.11 2021-07-05 +================ + +* Add Python versions 3.9.6, 3.7.11, 3.8.11, and 3.6.14 +* Format Python various files using black. (Not completely done yet though) + 5.0.10 2021-06-16 ================ diff --git a/xdis/opcodes/opcode_16.py b/xdis/opcodes/opcode_16.py index 42181213..37c7a5d3 100644 --- a/xdis/opcodes/opcode_16.py +++ b/xdis/opcodes/opcode_16.py @@ -1,4 +1,4 @@ -# (C) Copyright 2019-2020 by Rocky Bernstein +# (C) Copyright 2019-2021 by Rocky Bernstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -21,7 +21,7 @@ """ # This is used from outside this module -from xdis.cross_dis import findlabels, findlinestarts +from xdis.cross_dis import findlabels, findlinestarts # noqa import xdis.opcodes.opcode_15 as opcode_15 from xdis.opcodes.base import ( @@ -43,9 +43,10 @@ l = locals() init_opdata(l, opcode_15, version) +# fmt: off # 1.6 Bytecodes not in 1.5 -nargs_op(l, "CALL_FUNCTION_VAR", 140, -1, 1) # #args + (#kwargs << 8) -nargs_op(l, "CALL_FUNCTION_KW", 141, -1, 1) # #args + (#kwargs << 8) +nargs_op(l, "CALL_FUNCTION_VAR", 140, -1, 1) # #args + (#kwargs << 8) +nargs_op(l, "CALL_FUNCTION_KW", 141, -1, 1) # #args + (#kwargs << 8) nargs_op(l, "CALL_FUNCTION_VAR_KW", 142, -1, 1) # #args + (#kwargs << 8) update_pj2(globals(), l) @@ -53,17 +54,19 @@ opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg} opcode_arg_fmt = { - "EXTENDED_ARG": format_extended_arg, - "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded, - "CALL_FUNCTION_KW": format_CALL_FUNCTION_pos_name_encoded, + "EXTENDED_ARG": format_extended_arg, + "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded, + "CALL_FUNCTION_KW": format_CALL_FUNCTION_pos_name_encoded, "CALL_FUNCTION_VAR_KW": format_CALL_FUNCTION_pos_name_encoded, - "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc, + "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc, } opcode_extended_fmt = { - "LOAD_ATTR": extended_format_ATTR, + "LOAD_ATTR": extended_format_ATTR, "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older, - "RETURN_VALUE": extended_format_RETURN_VALUE, - "STORE_ATTR": extended_format_ATTR, + "RETURN_VALUE": extended_format_RETURN_VALUE, + "STORE_ATTR": extended_format_ATTR, } +# fmt: on + finalize_opcodes(l) diff --git a/xdis/opcodes/opcode_20.py b/xdis/opcodes/opcode_20.py index c0efd2f0..bc6fec51 100644 --- a/xdis/opcodes/opcode_20.py +++ b/xdis/opcodes/opcode_20.py @@ -1,4 +1,4 @@ -# (C) Copyright 2017, 2019, 2020 by Rocky Bernstein +# (C) Copyright 2017, 2019-2021 by Rocky Bernstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -39,28 +39,30 @@ l = locals() init_opdata(l, opcode_21, version) +# fmt: off # 2.1 Bytecodes not in 2.0 rm_op(l, "CONTINUE_LOOP", 119) -rm_op(l, "MAKE_CLOSURE", 134) -rm_op(l, "LOAD_CLOSURE", 135) -rm_op(l, "LOAD_DEREF", 136) -rm_op(l, "STORE_DEREF", 137) +rm_op(l, "MAKE_CLOSURE", 134) +rm_op(l, "LOAD_CLOSURE", 135) +rm_op(l, "LOAD_DEREF", 136) +rm_op(l, "STORE_DEREF", 137) update_pj2(globals(), l) finalize_opcodes(l) opcode_arg_fmt = { - "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded, - "CALL_FUNCTION_KW": format_CALL_FUNCTION_pos_name_encoded, + "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded, + "CALL_FUNCTION_KW": format_CALL_FUNCTION_pos_name_encoded, "CALL_FUNCTION_VAR_KW": format_CALL_FUNCTION_pos_name_encoded, - "EXTENDED_ARG": format_extended_arg, - "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc, + "EXTENDED_ARG": format_extended_arg, + "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc, } opcode_extended_fmt = { "LOAD_ATTR": extended_format_ATTR, - "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older, - "RETURN_VALUE": extended_format_RETURN_VALUE, - "STORE_ATTR": extended_format_ATTR, + "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older, + "RETURN_VALUE": extended_format_RETURN_VALUE, + "STORE_ATTR": extended_format_ATTR, } +# fmt: on diff --git a/xdis/opcodes/opcode_2x.py b/xdis/opcodes/opcode_2x.py index f91aad9d..68a5559a 100644 --- a/xdis/opcodes/opcode_2x.py +++ b/xdis/opcodes/opcode_2x.py @@ -1,4 +1,4 @@ -# (C) Copyright 2018, 2020 by Rocky Bernstein +# (C) Copyright 2018, 2020-2021 by Rocky Bernstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -23,43 +23,51 @@ """ from xdis.opcodes.base import ( - compare_op, const_op, - def_op, format_CALL_FUNCTION_pos_name_encoded, free_op, jabs_op, jrel_op, - local_op, name_op, nargs_op, store_op, - varargs_op - ) + compare_op, + const_op, + def_op, + free_op, + jabs_op, + jrel_op, + local_op, + name_op, + nargs_op, + store_op, + varargs_op, +) l = locals() # FIXME: DRY this with opcode_3x. -hascompare = [] -hascondition = [] # conditional operator; has jump offset -hasconst = [] -hasfree = [] -hasjabs = [] -hasjrel = [] -haslocal = [] -hasname = [] -hasnargs = [] # For function-like calls -hasstore = [] # Some sort of store operation -hasvargs = [] # Similar but for operators BUILD_xxx -nofollow = [] # Instruction doesn't fall to the next opcode +hascompare = [] +hascondition = [] # conditional operator; has jump offset +hasconst = [] +hasfree = [] +hasjabs = [] +hasjrel = [] +haslocal = [] +hasname = [] +hasnargs = [] # For function-like calls +hasstore = [] # Some sort of store operation +hasvargs = [] # Similar but for operators BUILD_xxx +nofollow = [] # Instruction doesn't fall to the next opcode # opmap[opcode_name] => opcode_number opmap = {} # opcode[i] => opcode name -opname = [''] * 256 +opname = [""] * 256 # oppush[op] => number of stack entries pushed oppush = [0] * 256 # oppop[op] => number of stack entries popped # 9 means handle special. Note his forces oppush[i] - oppop[i] negative -oppop = [0] * 256 +oppop = [0] * 256 -for op in range(256): opname[op] = '<%r>' % (op,) +for op in range(256): + opname[op] = "<%r>" % (op,) del op # Instruction opcodes for compiled code @@ -69,6 +77,7 @@ # (hasvargs | hasnargs) operation, then # the operand holds the size. +# fmt: off # OP NAME OPCODE POP PUSH #-------------------------------------------- def_op(l, "STOP_CODE", 0, 0, 0, fallthrough=False) @@ -210,4 +219,6 @@ nargs_op(l, "CALL_FUNCTION_VAR_KW", 142, -3, 1) # #args + (#kwargs << 8) def_op(l, "EXTENDED_ARG", 143) +# fmt: on + EXTENDED_ARG = 143 diff --git a/xdis/opcodes/opcode_37pypy.py b/xdis/opcodes/opcode_37pypy.py index 6f88827e..28de77b2 100644 --- a/xdis/opcodes/opcode_37pypy.py +++ b/xdis/opcodes/opcode_37pypy.py @@ -16,7 +16,6 @@ format_RAISE_VARARGS_older, format_extended_arg, init_opdata, - jrel_op, name_op, nargs_op, rm_op, @@ -38,51 +37,53 @@ init_opdata(l, opcode_37, version, is_pypy=True) -## FIXME: DRY common PYPY opcode additions +# FIXME: DRY common PYPY opcode additions +# fmt: off rm_op(l, "BUILD_TUPLE_UNPACK_WITH_CALL", 158) -rm_op(l, "LOAD_METHOD", 160) +rm_op(l, "LOAD_METHOD", 160) -nargs_op(l, "CALL_FUNCTION_KW", 141, 9, 1) # #args + (#kwargs << 8) -nargs_op(l, "CALL_FUNCTION_EX", 142, -2, 1) +nargs_op(l, "CALL_FUNCTION_KW", 141, 9, 1) # #args + (#kwargs << 8) +nargs_op(l, "CALL_FUNCTION_EX", 142, -2, 1) # The following were removed from 3.7 but still in Pypy 3.7 -store_op(l, 'STORE_ANNOTATION', 127, 1, 0, is_type="name") +store_op(l, 'STORE_ANNOTATION', 127, 1, 0, is_type="name") # PyPy only # ---------- -name_op(l, "LOOKUP_METHOD", 201, 1, 2) +name_op(l, "LOOKUP_METHOD", 201, 1, 2) l["hasvargs"].append(202) -nargs_op(l, "CALL_METHOD_KW", 204, -1, 1) +nargs_op(l, "CALL_METHOD_KW", 204, -1, 1) # Used only in single-mode compilation list-comprehension generators -varargs_op(l, "BUILD_LIST_FROM_ARG", 203) +varargs_op(l, "BUILD_LIST_FROM_ARG", 203) # PyPy 3.6.1 (and 2.7.13) start to introduce LOAD_REVDB_VAR import sys if sys.version_info[:3] >= (3, 6, 1): - def_op(l, "LOAD_REVDB_VAR", 205) + def_op(l, "LOAD_REVDB_VAR", 205) # FIXME remove (fix uncompyle6) update_pj3(globals(), l) opcode_arg_fmt = { - "EXTENDED_ARG": format_extended_arg, + "EXTENDED_ARG": format_extended_arg, "MAKE_FUNCTION": format_MAKE_FUNCTION_flags, "RAISE_VARARGS": format_RAISE_VARARGS_older, 'CALL_FUNCTION': format_CALL_FUNCTION_pos_name_encoded, } opcode_extended_fmt = { - "LOAD_ATTR": extended_format_ATTR, + "LOAD_ATTR": extended_format_ATTR, "MAKE_FUNCTION": extended_format_MAKE_FUNCTION, "RAISE_VARARGS": extended_format_RAISE_VARARGS_older, - "RETURN_VALUE": extended_format_RETURN_VALUE, - "STORE_ATTR": extended_format_ATTR, + "RETURN_VALUE": extended_format_RETURN_VALUE, + "STORE_ATTR": extended_format_ATTR, } +# Fmtxblackn: on finalize_opcodes(l) diff --git a/xdis/opcodes/opcode_39.py b/xdis/opcodes/opcode_39.py index b01c65e3..85b50e5d 100644 --- a/xdis/opcodes/opcode_39.py +++ b/xdis/opcodes/opcode_39.py @@ -19,7 +19,7 @@ This is a like Python 3.9's opcode.py """ -from xdis.opcodes.base import( +from xdis.opcodes.base import ( def_op, extended_format_ATTR, extended_format_RETURN_VALUE, @@ -27,8 +27,8 @@ init_opdata, jabs_op, rm_op, - update_pj3 - ) + update_pj3, +) from xdis.opcodes.opcode_36 import ( extended_format_CALL_FUNCTION, @@ -51,19 +51,20 @@ init_opdata(l, opcode_38, version) +# fmt: off # These are removed since 3.8... -rm_op(l, "BEGIN_FINALLY", 53) -rm_op(l, "WITH_CLEANUP_START", 81) +rm_op(l, "BEGIN_FINALLY", 53) +rm_op(l, "WITH_CLEANUP_START", 81) rm_op(l, "WITH_CLEANUP_FINISH", 82) -rm_op(l, "END_FINALLY", 88) -rm_op(l, "BUILD_LIST_UNPACK", 149) -rm_op(l, "BUILD_MAP_UNPACK", 150) +rm_op(l, "END_FINALLY", 88) +rm_op(l, "BUILD_LIST_UNPACK", 149) +rm_op(l, "BUILD_MAP_UNPACK", 150) rm_op(l, "BUILD_MAP_UNPACK_WITH_CALL", 151) rm_op(l, "BUILD_TUPLE_UNPACK", 152) -rm_op(l, "BUILD_SET_UNPACK", 153) +rm_op(l, "BUILD_SET_UNPACK", 153) rm_op(l, "BUILD_TUPLE_UNPACK_WITH_CALL", 158) -rm_op(l, "CALL_FINALLY", 162) -rm_op(l, "POP_FINALLY", 163) +rm_op(l, "CALL_FINALLY", 162) +rm_op(l, "POP_FINALLY", 163) # These are new since Python 3.9 @@ -85,9 +86,11 @@ format_value_flags = opcode_38.format_value_flags + def format_extended_is_op(arg): return "is" if arg == 0 else "is not" + def format_extended_contains_op(arg): return "in" if arg == 0 else "not in" @@ -96,23 +99,24 @@ def format_extended_contains_op(arg): "BUILD_MAP_UNPACK_WITH_CALL": format_BUILD_MAP_UNPACK_WITH_CALL, "CALL_FUNCTION_EX": format_CALL_FUNCTION_EX, "CALL_FUNCTION_KW": format_CALL_FUNCTION_KW, - 'CONTAINS_OP': format_extended_contains_op, - 'EXTENDED_ARG': format_extended_arg36, - 'FORMAT_VALUE': format_value_flags, - 'IS_OP': format_extended_is_op, - 'MAKE_FUNCTION': format_MAKE_FUNCTION_flags, - "RAISE_VARARGS": format_RAISE_VARARGS + "CONTAINS_OP": format_extended_contains_op, + "EXTENDED_ARG": format_extended_arg36, + "FORMAT_VALUE": format_value_flags, + "IS_OP": format_extended_is_op, + "MAKE_FUNCTION": format_MAKE_FUNCTION_flags, + "RAISE_VARARGS": format_RAISE_VARARGS, } opcode_extended_fmt = { "CALL_FUNCTION": extended_format_CALL_FUNCTION, - "LOAD_ATTR": extended_format_ATTR, - "CALL_METHOD": extended_format_CALL_METHOD, + "CALL_METHOD": extended_format_CALL_METHOD, + "LOAD_ATTR": extended_format_ATTR, "MAKE_FUNCTION": extended_format_MAKE_FUNCTION, "RAISE_VARARGS": extended_format_RAISE_VARARGS, - "RETURN_VALUE": extended_format_RETURN_VALUE, - "STORE_ATTR": extended_format_ATTR, + "RETURN_VALUE": extended_format_RETURN_VALUE, + "STORE_ATTR": extended_format_ATTR, } +# fmt: on update_pj3(globals(), l) diff --git a/xdis/opcodes/opcode_3x.py b/xdis/opcodes/opcode_3x.py index 48bac7ee..09af40d7 100644 --- a/xdis/opcodes/opcode_3x.py +++ b/xdis/opcodes/opcode_3x.py @@ -1,4 +1,4 @@ -# (C) Copyright 2017-2018, 2020 by Rocky Bernstein +# (C) Copyright 2017-2018, 2020-2021 by Rocky Bernstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -24,43 +24,51 @@ """ from xdis.opcodes.base import ( - compare_op, const_op, - def_op, format_extended_arg, - free_op, jabs_op, jrel_op, - local_op, name_op, nargs_op, store_op, - varargs_op - ) + compare_op, + const_op, + def_op, + format_extended_arg, + free_op, + jabs_op, + jrel_op, + local_op, + name_op, + nargs_op, + store_op, + varargs_op, +) l = locals() # FIXME: DRY with opcode2x.py -hascompare = [] -hascondition = [] # conditional operator; has jump offset -hasconst = [] -hasfree = [] -hasjabs = [] -hasjrel = [] -haslocal = [] -hasname = [] -hasnargs = [] # For function-like calls -hasstore = [] # Some sort of store operation -hasvargs = [] # Similar but for operators BUILD_xxx -nofollow = [] # Instruction doesn't fall to the next opcode +hascompare = [] +hascondition = [] # conditional operator; has jump offset +hasconst = [] +hasfree = [] +hasjabs = [] +hasjrel = [] +haslocal = [] +hasname = [] +hasnargs = [] # For function-like calls +hasstore = [] # Some sort of store operation +hasvargs = [] # Similar but for operators BUILD_xxx +nofollow = [] # Instruction doesn't fall to the next opcode # opmap[opcode_name] => opcode_number opmap = {} # opcode[i] => opcode name -opname = [''] * 256 +opname = [""] * 256 # oppush[op] => number of stack entries pushed oppush = [0] * 256 # oppop[op] => number of stack entries popped -oppop = [0] * 256 +oppop = [0] * 256 -for op in range(256): opname[op] = '<%r>' % (op,) +for op in range(256): + opname[op] = "<%r>" % (op,) del op # Instruction opcodes for compiled code @@ -72,6 +80,7 @@ # If the POP field is negative and the opcode is a nargs operation # then pop the operand amount plus the negative of the POP amount. +# fmt: off # OP NAME OPCODE POP PUSH #-------------------------------------------- def_op(l, 'STOP_CODE', 0, 0, 0, fallthrough=False) @@ -221,8 +230,8 @@ # Used to implement dict comprehensions. def_op(l, 'EXTENDED_ARG', 144, 0, 0) +# fmt: on + EXTENDED_ARG = 144 -opcode_arg_fmt = { - 'EXTENDED_ARG': format_extended_arg -} +opcode_arg_fmt = {"EXTENDED_ARG": format_extended_arg} diff --git a/xdis/version.py b/xdis/version.py index c6489c26..e81c377b 100644 --- a/xdis/version.py +++ b/xdis/version.py @@ -4,4 +4,4 @@ # well as importing into Python. That's why there is no # space around "=" below. # fmt: off -__version__="5.0.11.dev0" # noqa +__version__="5.0.11" # noqa