Skip to content

Commit

Permalink
Get ready for release 5.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jul 6, 2021
1 parent ae35f3b commit 56dcc49
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 105 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
================

Expand Down
25 changes: 14 additions & 11 deletions xdis/opcodes/opcode_16.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 (
Expand All @@ -43,27 +43,30 @@
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)

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)
26 changes: 14 additions & 12 deletions xdis/opcodes/opcode_20.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
53 changes: 32 additions & 21 deletions xdis/opcodes/opcode_2x.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
29 changes: 15 additions & 14 deletions xdis/opcodes/opcode_37pypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
format_RAISE_VARARGS_older,
format_extended_arg,
init_opdata,
jrel_op,
name_op,
nargs_op,
rm_op,
Expand All @@ -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)
46 changes: 25 additions & 21 deletions xdis/opcodes/opcode_39.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
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,
finalize_opcodes,
init_opdata,
jabs_op,
rm_op,
update_pj3
)
update_pj3,
)

from xdis.opcodes.opcode_36 import (
extended_format_CALL_FUNCTION,
Expand All @@ -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
Expand All @@ -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"

Expand All @@ -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)

Expand Down
Loading

0 comments on commit 56dcc49

Please sign in to comment.