How to use the xdis.opcodes.base.rm_op function in xdis

To help you get started, we’ve selected a few xdis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocky / python-xdis / xdis / opcodes / opcode_39.py View on Github external
format_extended_arg36,
)

from xdis.opcodes.opcode_36 import format_MAKE_FUNCTION_flags
import xdis.opcodes.opcode_38 as opcode_38

version = 3.9
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_38, version)

# These are removed since 3.8...
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, "CALL_FINALLY", 162)
rm_op(l, "POP_FINALLY", 163)


# These are new since Python 3.9

#          OP NAME              OPCODE  POP PUSH
#-----------------------------------------------
def_op(l, 'RERAISE',                48,   3, 0)
def_op(l, 'WITH_EXCEPT_START',      49,   0, 1)
def_op(l, 'LOAD_ASSERTION_ERROR',   74,   0, 1)

format_value_flags = opcode_38.format_value_flags
github rocky / python-xdis / xdis / opcodes / opcode_38.py View on Github external
format_MAKE_FUNCTION_flags,
    format_extended_arg36,
)

version = 3.8
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_37, version)

# These are removed since 3.7...
rm_op(l, "BREAK_LOOP", 80)
rm_op(l, "CONTINUE_LOOP", 119)
rm_op(l, "SETUP_LOOP", 120)
rm_op(l, "SETUP_EXCEPT", 121)

# These are new since Python 3.7

#          OP NAME            OPCODE POP PUSH
# --------------------------------------------
def_op(l, "ROT_FOUR", 6, 4, 4)
def_op(l, "BEGIN_FINALLY", 53, 0, 6)
def_op(l, "END_ASYNC_FOR", 54, 7, 0)  # POP is 0, when not 7
def_op(l, "END_FINALLY", 88, 6, 0)  # POP is 6, when not 1
jrel_op(l, "CALL_FINALLY", 162, 0, 1)
nargs_op(l, "POP_FINALLY", 163, 6, 0)  # PUSH/POP vary

format_value_flags = opcode_37.format_value_flags

opcode_arg_fmt = {
    "BUILD_MAP_UNPACK_WITH_CALL": format_BUILD_MAP_UNPACK_WITH_CALL,
github rocky / python-xdis / xdis / opcodes / opcode_30.py View on Github external
)

import xdis.opcodes.opcode_31 as opcode_31

version = 3.0
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_31, version)

# These are in Python 3.x but not in Python 3.0

rm_op(l, 'JUMP_IF_FALSE_OR_POP', 111)
rm_op(l, 'JUMP_IF_TRUE_OR_POP',  112)
rm_op(l, 'POP_JUMP_IF_FALSE',    114)
rm_op(l, 'POP_JUMP_IF_TRUE',     115)
rm_op(l, 'LIST_APPEND',          145)
rm_op(l, 'MAP_ADD',              147)

# These are are in 3.0 but are not in 3.1 or they have
# different opcode numbers. Note: As a result of opcode value
# changes, these have to be applied *after* removing ops (with
# the same name).

#          OP NAME            OPCODE POP PUSH
#--------------------------------------------

def_op(l, 'SET_ADD',              17, 2, 0)  # Calls set.add(TOS1[-i], TOS).
                                             # Used to implement set comprehensions.
def_op(l, 'LIST_APPEND',          18, 2, 0)  # Calls list.append(TOS1, TOS).
                                             # Used to implement list comprehensions.
github rocky / python-xdis / xdis / opcodes / opcode_39.py View on Github external
import xdis.opcodes.opcode_38 as opcode_38

version = 3.9
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_38, version)

# These are removed since 3.8...
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, "CALL_FINALLY", 162)
rm_op(l, "POP_FINALLY", 163)


# These are new since Python 3.9

#          OP NAME              OPCODE  POP PUSH
#-----------------------------------------------
def_op(l, 'RERAISE',                48,   3, 0)
def_op(l, 'WITH_EXCEPT_START',      49,   0, 1)
def_op(l, 'LOAD_ASSERTION_ERROR',   74,   0, 1)

format_value_flags = opcode_38.format_value_flags

opcode_arg_fmt = {
    "BUILD_MAP_UNPACK_WITH_CALL": format_BUILD_MAP_UNPACK_WITH_CALL,
    "CALL_FUNCTION_KW": format_CALL_FUNCTION_KW,
    "CALL_FUNCTION_EX": format_CALL_FUNCTION_EX,
github rocky / python-xdis / xdis / opcodes / opcode_20.py View on Github external
format_MAKE_FUNCTION_default_argc,
    format_extended_arg,
    rm_op,
    update_pj2,
)

version = 2.0
python_implementation = "CPython"

l = locals()
init_opdata(l, opcode_21, version)

# 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)

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_VAR_KW": format_CALL_FUNCTION_pos_name_encoded,
    "EXTENDED_ARG": format_extended_arg,
    "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc,
}

opcode_extended_fmt = {
github rocky / python-xdis / xdis / opcodes / opcode_35.py View on Github external
from xdis.opcodes.opcode_33 import (
    extended_format_MAKE_FUNCTION,
    format_MAKE_FUNCTION_default_pos_arg,
)

version = 3.5
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_34, version)

# These are removed since Python 3.5.
# Removals happen before adds since
# some opcodes are reused
rm_op(l, "STORE_MAP",                    54)
rm_op(l, "WITH_CLEANUP",                 81)

# Stack effects are change from 3.4
varargs_op(l, "BUILD_MAP",              105, -1, -1)  # arg is count of kwarg items

# These are new since Python 3.5
#          OP NAME                   OPCODE POP PUSH
#---------------------------------------------------
def_op(l, "BINARY_MATRIX_MULTIPLY",      16,  2,  1)
def_op(l, "INPLACE_MATRIX_MULTIPLY",     17,  2,  1)
def_op(l, "GET_AITER",                   50,  1,  1)
def_op(l, "GET_ANEXT",                   51,  0,  1)
def_op(l, "BEFORE_ASYNC_WITH",           52,  0,  1)
def_op(l, "GET_YIELD_FROM_ITER",         69,  1,  1)
def_op(l, "GET_AWAITABLE",               73,  0,  0)
def_op(l, "WITH_CLEANUP_START",          81,  0,  1)
github rocky / python-xdis / xdis / opcodes / opcode_27.py View on Github external
rm_op,
    update_pj3,
    varargs_op,
)

import xdis.opcodes.opcode_26 as opcode_26

version = 2.7
python_implementation = "CPython"

l = locals()
init_opdata(l, opcode_26, version)

# Below are opcode changes since Python 2.6
rm_op(l, "BUILD_MAP", 104)
rm_op(l, "LOAD_ATTR", 105)
rm_op(l, "COMPARE_OP", 106)
rm_op(l, "IMPORT_NAME", 107)
rm_op(l, "IMPORT_FROM", 108)
rm_op(l, "JUMP_IF_FALSE", 111)
rm_op(l, "EXTENDED_ARG", 143)
rm_op(l, "JUMP_IF_TRUE", 112)

# These have changed since 2.6 in stack effects.
#          OP NAME            OPCODE   POP PUSH
#-----------------------------------------------
def_op(l, "END_FINALLY",            88,  3,  0)
jrel_op(l, "SETUP_EXCEPT",         121,  0,  0, conditional=True)  # ""
jrel_op(l, "SETUP_FINALLY" ,       122,  0,  0, conditional=True)  # ""


def_op(l, "LIST_APPEND",            94,  2,  1)  # Calls list.append(TOS[-i], TOS).
github rocky / python-xdis / xdis / opcodes / opcode_37.py View on Github external
# of keyword arguments if bit 0 of *oparg* is 1.


# MAKE_FUNCTION oparg

# This is a different opcode from before.

# The tuple of default values for positional-or-keyword parameters,
# the dict of default values for keyword-only parameters, the dict of
# annotations and the closure are pushed on the stack if corresponding
# bit (0-3) is set. They are followed by the code object and the
# qualified name of the function.

# These are removed since 3.6...
# and STORE_ANNOTATION introduced in 3.6!
rm_op(l, "STORE_ANNOTATION", 127)

# These have a changed stack effect since 3.6
#          OP NAME            OPCODE POP PUSH
#---------------------------------------------------------------
def_op(l, "WITH_CLEANUP_START",   81,  0,  2)
def_op(l, "WITH_CLEANUP_FINISH",  82,  3,  0)
def_op(l, "END_FINALLY",          88,  6,  0)
def_op(l, "POP_EXCEPT",           89,  3,  0) # Pops last 3 values
jrel_op(l, "SETUP_WITH",         143,  0,  6)
jrel_op(l, "SETUP_ASYNC_WITH",   154,  0,  5)

# These are new since Python 3.7
name_op(l, "LOAD_METHOD", 160, 0, 1)
nargs_op(l, "CALL_METHOD", 161, -2, 1)

format_MAKE_FUNCTION_flags = opcode_36.format_MAKE_FUNCTION_flags
github rocky / python-xdis / xdis / opcodes / opcode_38.py View on Github external
format_CALL_FUNCTION_EX,
    format_CALL_FUNCTION_KW,
    format_MAKE_FUNCTION_flags,
    format_extended_arg36,
)

version = 3.8
python_implementation = "CPython"

l = locals()

init_opdata(l, opcode_37, version)

# These are removed since 3.7...
rm_op(l, "BREAK_LOOP", 80)
rm_op(l, "CONTINUE_LOOP", 119)
rm_op(l, "SETUP_LOOP", 120)
rm_op(l, "SETUP_EXCEPT", 121)

# These are new since Python 3.7

#          OP NAME            OPCODE POP PUSH
# --------------------------------------------
def_op(l, "ROT_FOUR", 6, 4, 4)
def_op(l, "BEGIN_FINALLY", 53, 0, 6)
def_op(l, "END_ASYNC_FOR", 54, 7, 0)  # POP is 0, when not 7
def_op(l, "END_FINALLY", 88, 6, 0)  # POP is 6, when not 1
jrel_op(l, "CALL_FINALLY", 162, 0, 1)
nargs_op(l, "POP_FINALLY", 163, 6, 0)  # PUSH/POP vary

format_value_flags = opcode_37.format_value_flags
github rocky / python-xdis / xdis / opcodes / opcode_13.py View on Github external
extended_format_RETURN_VALUE,
    rm_op,
    finalize_opcodes,
    format_extended_arg,
    # Although these aren't used here, they are exported
    update_pj2,
)

version = 1.3
python_implementation = "CPython"

l = locals()
init_opdata(l, opcode_14, version)

# 1.3 - 1.4 bytecodes differences
rm_op(l, "BINARY_POWER", 19)
def_op(l, "LOAD_GLOBALS", 84)

update_pj2(globals(), l)

opcode_arg_fmt = {
    "EXTENDED_ARG": format_extended_arg
}

finalize_opcodes(l)

opcode_extended_fmt = {
    "RETURN_VALUE": extended_format_RETURN_VALUE,
}

findlinestarts = opcode_14.findlinestarts