pypy-venv/bin/pypy3 -m pytest -D ../build/pypy --junitxml=test-D.log
in dir /build_dir/pypy-c-jit-linux-x86-64/venv (timeout 1200 secs)
watching logfiles {'pytestLog': 'test-D.log'}
argv: ['pypy-venv/bin/pypy3', '-m', 'pytest', '-D', '../build/pypy', '--junitxml=test-D.log']
environment:
AUDITWHEEL_ARCH=x86_64
AUDITWHEEL_PLAT=manylinux2014_x86_64
AUDITWHEEL_POLICY=manylinux2014
DEVTOOLSET_ROOTPATH=/opt/rh/devtoolset-10/root
HOME=/home/buildslave
HOSTNAME=255659ffae49
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LD_LIBRARY_PATH=/usr/local/lib:/opt/rh/devtoolset-10/root/usr/lib64:/opt/rh/devtoolset-10/root/usr/lib:/opt/rh/devtoolset-10/root/usr/lib64/dyninst:/opt/rh/devtoolset-10/root/usr/lib/dyninst:/usr/local/lib64
LOGNAME=buildslave
PATH=/python27_virt/bin:/opt/rh/devtoolset-10/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig
PWD=/build_dir/pypy-c-jit-linux-x86-64/venv
PYPY_LOCALBASE=/usr/local
PYPY_MAKE_PORTABLE=1
PYPY_USESSION_DIR=/tmp/pytest
SHELL=/bin/bash
SHLVL=2
SSL_CERT_FILE=/opt/_internal/certs.pem
TERM=xterm
USER=buildslave
USE_CURL=1
_=/python27_virt/bin/buildslave
using PTY: False
============================= test session starts ==============================
platform linux -- Python 3.12.13[pypy-7.3.24-alpha], pytest-6.2.5, py-1.11.0, pluggy-1.6.0
pytest-6.2.5 from /build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/pytest/__init__.py
rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, configfile: pytest.ini
plugins: xdist-3.5.0, hypothesis-6.36.2
collected 2055 items
../build/pypy/interpreter/astcompiler/test/apptest_compiler.py ....... [ 0%]
../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py F.. [ 0%]
.................F.F.. [ 1%]
../build/pypy/interpreter/astcompiler/test/apptest_fstring.py .......... [ 2%]
.............. [ 2%]
../build/pypy/interpreter/astcompiler/test/apptest_misc.py ............. [ 3%]
.. [ 3%]
../build/pypy/interpreter/astcompiler/test/apptest_patma.py ............ [ 4%]
....................F........ [ 5%]
../build/pypy/interpreter/pyparser/test/apptest_parsestring.py ....F. [ 5%]
../build/pypy/interpreter/test/apptest_annotations.py .................. [ 6%]
........ [ 7%]
../build/pypy/interpreter/test/apptest_annotations_string.py ...... [ 7%]
../build/pypy/interpreter/test/apptest_buffer.py ..... [ 7%]
../build/pypy/interpreter/test/apptest_class.py ................ [ 8%]
../build/pypy/interpreter/test/apptest_coroutine.py .................... [ 9%]
................................. [ 10%]
../build/pypy/interpreter/test/apptest_descrtypecheck.py .. [ 10%]
../build/pypy/interpreter/test/apptest_exceptions.py ........s.......... [ 11%]
.F...F. [ 12%]
../build/pypy/interpreter/test/apptest_exctable_dis.py FFFFFF..F [ 12%]
../build/pypy/interpreter/test/apptest_exec.py ......................... [ 13%]
[ 13%]
../build/pypy/interpreter/test/apptest_extcall.py ..... [ 14%]
../build/pypy/interpreter/test/apptest_function.py ..................... [ 15%]
................s..................................................... [ 18%]
../build/pypy/interpreter/test/apptest_generator.py .................... [ 19%]
............................................... [ 21%]
../build/pypy/interpreter/test/apptest_nestedscope.py .................. [ 22%]
[ 22%]
../build/pypy/interpreter/test/apptest_pep695.py ....................... [ 23%]
........ [ 24%]
../build/pypy/interpreter/test/apptest_pycode.py .... [ 24%]
../build/pypy/interpreter/test/apptest_pyframe.py ...................... [ 25%]
.......................................... [ 27%]
../build/pypy/interpreter/test/apptest_raise.py ..........F.......F..... [ 28%]
.............................. [ 30%]
../build/pypy/interpreter/test/apptest_settrace_jump.py . [ 30%]
../build/pypy/interpreter/test/apptest_sys_settrace.py ................. [ 31%]
........................................................................ [ 34%]
..................................................... [ 37%]
../build/pypy/interpreter/test/apptest_traceback.py ....F.F. [ 37%]
../build/pypy/interpreter/test/apptest_unraisable.py .... [ 37%]
../build/pypy/interpreter/test/apptest_with_leak.py .....FFFF [ 38%]
../build/pypy/module/__builtin__/test/apptest_compile.py ............... [ 38%]
...... [ 39%]
../build/pypy/module/__builtin__/test/apptest_descriptor.py ..... [ 39%]
../build/pypy/module/__builtin__/test/apptest_operator.py ... [ 39%]
../build/pypy/module/__builtin__/test/apptest_print.py ... [ 39%]
../build/pypy/module/__pypy__/test/apptest_picklebuffer.py ...... [ 40%]
../build/pypy/module/_abc/test/apptest_abc.py ... [ 40%]
../build/pypy/module/_ast/test/apptest_ast.py ... [ 40%]
../build/pypy/module/_codecs/test/apptest_codecs.py .. [ 40%]
../build/pypy/module/_collections/test/apptest_defaultdict.py .......... [ 40%]
.... [ 41%]
../build/pypy/module/_collections/test/apptest_deque.py ................ [ 41%]
.......................... [ 43%]
../build/pypy/module/_collections/test/apptest_ordereddict.py .......... [ 43%]
[ 43%]
../build/pypy/module/_csv/test/apptest_writer.py ...... [ 43%]
../build/pypy/module/_io/test/apptest_bufferedio.py . [ 43%]
../build/pypy/module/_io/test/apptest_bytesio.py ................. [ 44%]
../build/pypy/module/_io/test/apptest_io.py ............................ [ 46%]
............... [ 46%]
../build/pypy/module/_io/test/apptest_stringio.py ...................... [ 47%]
..... [ 48%]
../build/pypy/module/_io/test/apptest_textio.py ........................ [ 49%]
......s................. [ 50%]
../build/pypy/module/_multibytecodec/test/apptest_codecs.py ............ [ 51%]
....... [ 51%]
../build/pypy/module/_multibytecodec/test/apptest_incremental.py ....... [ 51%]
............. [ 52%]
../build/pypy/module/_multibytecodec/test/apptest_stream.py ..... [ 52%]
../build/pypy/module/_opcode/test/apptest_opcode.py ..... [ 52%]
../build/pypy/module/_pickle/test/apptest_optional_frames.py .. [ 52%]
../build/pypy/module/_pickle/test/apptest_pickle.py .................... [ 53%]
..F........................................s... [ 56%]
../build/pypy/module/_pickle/test/apptest_pypy_extensions.py ........... [ 56%]
................ [ 57%]
../build/pypy/module/_pickle_support/test/apptest__pickle_support.py . [ 57%]
../build/pypy/module/_posixsubprocess/test/apptest_subprocess.py ....... [ 57%]
.. [ 58%]
../build/pypy/module/_pypyjson/test/apptest__pypyjson.py ........ [ 58%]
../build/pypy/module/_rawffi/test/apptest_rawffi.py .. [ 58%]
../build/pypy/module/_socket/test/apptest_socket.py .................... [ 59%]
.ss..................s................s... [ 61%]
../build/pypy/module/_sre/test/apptest_sre.py .......................... [ 62%]
........................................... [ 64%]
../build/pypy/module/_warnings/test/apptest_warnings.py ........s.s..... [ 65%]
[ 65%]
../build/pypy/module/_weakref/test/apptest_weakref.py .................. [ 66%]
......................... [ 67%]
../build/pypy/module/array/test/apptest_array.py ... [ 67%]
../build/pypy/module/atexit/test/apptest_atexit.py .. [ 68%]
../build/pypy/module/bz2/test/apptest_bz2_compdecomp.py .s... [ 68%]
../build/pypy/module/exceptions/test/apptest_exceptions.py ............. [ 68%]
..................................... [ 70%]
../build/pypy/module/itertools/test/apptest_itertools.py .... [ 70%]
../build/pypy/module/marshal/test/apptest_marshal.py ................... [ 71%]
............................ [ 73%]
../build/pypy/module/math/test/apptest_math.py ............F [ 73%]
../build/pypy/module/posix/test/apptest_posix.py .... [ 74%]
../build/pypy/module/pyexpat/test/apptest_pyexpat.py ... [ 74%]
../build/pypy/module/signal/test/apptest_signal.py . [ 74%]
../build/pypy/module/struct/test/apptest_struct.py ..................... [ 75%]
..................... [ 76%]
../build/pypy/module/struct/test/apptest_structbuffer.py .. [ 76%]
../build/pypy/module/sys/test/apptest_audit.py .......... [ 76%]
../build/pypy/module/sys/test/apptest_initpath.py . [ 76%]
../build/pypy/module/sys/test/apptest_sys.py . [ 76%]
../build/pypy/module/time/test/apptest_time.py ........................s [ 78%]
................ [ 78%]
../build/pypy/module/token/test/apptest_token.py ........ [ 79%]
../build/pypy/module/zipimport/test/apptest_zipimport.py . [ 79%]
../build/pypy/objspace/std/test/apptest_boolobject.py ......... [ 79%]
../build/pypy/objspace/std/test/apptest_callmethod.py .......... [ 80%]
../build/pypy/objspace/std/test/apptest_complexobject.py ............... [ 81%]
..................... [ 82%]
../build/pypy/objspace/std/test/apptest_contains.py .. [ 82%]
../build/pypy/objspace/std/test/apptest_instmethobject.py ..... [ 82%]
../build/pypy/objspace/std/test/apptest_iterobject.py .................. [ 83%]
... [ 83%]
../build/pypy/objspace/std/test/apptest_memoryobject.py ........ [ 83%]
../build/pypy/objspace/std/test/apptest_operation.py . [ 83%]
../build/pypy/objspace/std/test/apptest_specializedtuple.py ............ [ 84%]
............ [ 85%]
../build/pypy/objspace/std/test/apptest_stringformat.py ................ [ 85%]
.s......s..................s........................ [ 88%]
../build/pypy/objspace/std/test/apptest_tuple.py ....................... [ 89%]
. [ 89%]
../build/pypy/objspace/std/test/apptest_typeobjject.py ........ [ 89%]
../build/pypy/objspace/std/test/apptest_unicode.py ..................... [ 90%]
......s................................................................. [ 94%]
......................... [ 95%]
../build/pypy/objspace/std/test/apptest_userobject.py .................. [ 96%]
...... [ 96%]
../build/pypy/objspace/test/apptest_binop_overriding.py . [ 96%]
../build/pypy/objspace/test/apptest_descriptor.py ....s.... [ 97%]
../build/pypy/objspace/test/apptest_descroperation.py ................s. [ 98%]
..................................... [ 99%]
../build/pypy/tool/pytest/fake_pytest/test/apptest_fake_pytest.py . [100%]
=================================== FAILURES ===================================
_______________________ test_with_try_except_as_reraise ________________________
def test_with_try_except_as_reraise():
"""with + try/except T as name where the handler raises: the new exception
must propagate through the with block's __exit__ without crashing.
Mirrors import_helper.import_module: with CM(): try: ... except E as msg: raise Other"""
class CM:
def __init__(self): self.exited = False; self.exc_type = None
def __enter__(self): return self
def __exit__(self, tp, val, tb):
self.exited = True
self.exc_type = tp
return False # do not suppress
cm = CM()
# normal_return=True exercises the normal-exit path so POP_BLOCK fires,
# mirroring import_helper.import_module which also has a normal return.
def inner(cm, raise_in_handler):
with cm:
try:
if raise_in_handler:
raise ValueError("original")
return "ok"
except ValueError as e:
raise TypeError("new")
print("=== dis(inner) ===")
> dis.dis(inner)
../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'|\x005\x00\x01\x00\t\x00|\x01r\nt\x00d\x01\x83\x01\x82\x01\t\x00d\x00\x08\x00\x08\x00\x83\x03\x01\x00d\x02S\x00#\x00...x82\x01d\x00}\x02~\x02w\x01w\x00&\x03Y\x00w\x01#\x001\x00s*w\x02&\x03Y\x00w\x01\x01\x00Y\x00\x01\x00\x01\x00d\x00S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object inner at 0x00007f43ad09a128, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py", line 21>>
names = ('ValueError', 'TypeError'), co_consts = (None, 'original', 'ok', 'new')
linestarts = {0: 22, 6: 23, 8: 24, 12: 25, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=4, end=8, target=70, depth=1, lasti=True), _ExceptionTableEntry(start=8, end=22, target=36..., end=64, target=64, depth=2, lasti=True), _ExceptionTableEntry(start=64, end=70, target=70, depth=1, lasti=True), ...]
co_positions = <sequenceiterator object at 0x0000000006ad0b60>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== dis(inner) ===
22 0 LOAD_FAST 0 (cm)
2 BEFORE_WITH
4 POP_TOP
23 6 NOP
24 8 LOAD_FAST 1 (raise_in_handler)
10 POP_JUMP_IF_FALSE 10 (to 20)
25 12 LOAD_GLOBAL 0 (ValueError)
22 22 LOAD_CONST 0 (None)
24 DUP_TOP
26 DUP_TOP
_______________________ test_except_star_cleanup_lineno ________________________
def test_except_star_cleanup_lineno():
"""Cleanup opcodes (LIST_APPEND) after except* must not be attributed to a
line before the except* clause (e.g. co_firstlineno of the function) — that
would misreport where the cleanup runs."""
def func():
try:
raise KeyError
except* Exception as e:
pass
> except_star_line = _except_star_clause_line(func)
../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py:372:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py:357: in _except_star_clause_line
instrs = list(dis.get_instructions(func))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00t\x00\x82\x01#\x00&\x01g\x00c\x02t\x01%\x00&\x01\x9a\x0b}\x00d\x00}\x00~\x00n\x07d\x00}\x00~\x00\x91\x03\x01\x00n\x01\x01\x00\x91\x01X\x00&\x01\x9e\x07\x01\x00Y\x00d\x00S\x00c\x02Y\x00w\x00c\x02Y\x00w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object func at 0x00007f43acff6860, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py", line 366>>
names = ('KeyError', 'Exception'), co_consts = (None,)
linestarts = {0: 367, 2: 368, 8: 369, 24: 370, ...}, line_offset = 0
exception_entries = ()
co_positions = <sequenceiterator object at 0x0000000002079070>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
_____________________ test_except_star_trace_return_lineno _____________________
def test_except_star_trace_return_lineno():
"""The 'return' trace event after an except* block should report the except*
clause line, not co_firstlineno (which was the wrong pre-fix behaviour)."""
events = []
def tracer(frame, event, arg):
if frame.f_code.co_name == 'func':
events.append((event, frame.f_lineno))
return tracer
def func():
try:
raise KeyError
except* Exception as e:
pass
> except_star_line = _except_star_clause_line(func)
../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py:425:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py:357: in _except_star_clause_line
instrs = list(dis.get_instructions(func))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00t\x00\x82\x01#\x00&\x01g\x00c\x02t\x01%\x00&\x01\x9a\x0b}\x00d\x00}\x00~\x00n\x07d\x00}\x00~\x00\x91\x03\x01\x00n\x01\x01\x00\x91\x01X\x00&\x01\x9e\x07\x01\x00Y\x00d\x00S\x00c\x02Y\x00w\x00c\x02Y\x00w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object func at 0x00007f43acff70a0, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py", line 419>>
names = ('KeyError', 'Exception'), co_consts = (None,)
linestarts = {0: 420, 2: 421, 8: 422, 24: 423, ...}, line_offset = 0
exception_entries = ()
co_positions = <sequenceiterator object at 0x00007f43b03bb4d8>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
_______________ test_match_mapping_codegen_uses_unpack_sequence ________________
def test_match_mapping_codegen_uses_unpack_sequence():
"""MATCH_KEYS result should be unpacked with UNPACK_SEQUENCE, not
with DUP_TOP+BINARY_SUBSCR+rotation. CPython emits:
MATCH_KEYS / COPY 1 / POP_JUMP_FORWARD_IF_NONE / UNPACK_SEQUENCE n
PyPy must match that pattern to avoid emitting SWAP instructions."""
import dis
def f(x):
match x:
case {'a': a, 'b': b, 'c': _}:
return a, b
> instrs = list(dis.get_instructions(f))
../build/pypy/interpreter/astcompiler/test/apptest_patma.py:372:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'|\x00\x1f\x00r\x19\x1e\x00d\x01k\x05r\x19d\x02!\x00&\x01d\x00u\x01r\x17\\\x03}\x01}\x02\x01\x00\x01\x00\x01\x00|\x01|\x02f\x02S\x00\x01\x00\x01\x00\x01\x00d\x00S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object f at 0x00007f43ad2bc338, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/astcompiler/test/apptest_patma.py", line 367>>
names = (), co_consts = (None, 3, ('a', 'b', 'c'))
linestarts = {0: 368, 2: 369, 38: 370, 46: 369}, line_offset = 0
exception_entries = ()
co_positions = <sequenceiterator object at 0x000000000500bb50>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
____________________ test_invalid_escape_syntax_error_span _____________________
def test_invalid_escape_syntax_error_span():
# When -Werror promotes the SyntaxWarning to a SyntaxError, the
# error should highlight the full string token, not just one character.
# E.g. for '"""\q"""' (8 chars) the end offset must be start+8.
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('error', category=SyntaxWarning)
with raises(SyntaxError) as excinfo:
eval('"""\\q"""')
assert not w
exc = excinfo.value
# offset is 1-based column of opening quote; end_offset covers
# the full token '"""\q"""' (8 chars).
> assert exc.end_offset - exc.offset == len('"""\\q"""')
E assert (8 - 1) == 8
E + where 8 = SyntaxError("invalid escape sequence '\\q'", ('<string>', 1, 1, '"""\\q"""', 1, 8)).end_offset
E + and 1 = SyntaxError("invalid escape sequence '\\q'", ('<string>', 1, 1, '"""\\q"""', 1, 8)).offset
E + and 8 = len('"""\\q"""')
../build/pypy/interpreter/pyparser/test/apptest_parsestring.py:69: AssertionError
_______________________ test_nested_except_raise_stored ________________________
def test_nested_except_raise_stored():
# CPython 3.11 exception table for this pattern:
# try body -> outer_handler
# inner try body -> inner_handler
# inner handler check+STORE -> inner outer_cleanup
# inner handler body (incl RAISE_VARARGS) -> inner cleanup_end
# inner cleanup_end -> inner outer_cleanup
# outer handler check -> outer outer_cleanup
import dis
def f():
try:
z = 0
try:
"x" + 1
except TypeError as e:
z = 5
raise e
except TypeError:
return z
print()
> dis.dis(f)
../build/pypy/interpreter/test/apptest_exceptions.py:320:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00d\x01}\x00\t\x00d\x02d\x03\x17\x00\x01\x00d\x00S\x00#\x00t\x00$\x00r\x17}\x01d\x04}\x00|\x01\x82\x01d\x00}\x01~\x01w\x01w\x00&\x03Y\x00w\x01#\x00t\x00$\x00r%\x01\x00|\x00\x06\x00Y\x00S\x00w\x01w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object f at 0x00007f43ac295bf8, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exceptions.py", line 309>>
names = ('TypeError',), co_consts = (None, 0, 'x', 1, 5)
linestarts = {0: 310, 2: 311, 6: 312, 8: 313, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=8, target=54, depth=0, lasti=False), _ExceptionTableEntry(start=8, end=16, target=2... end=48, target=48, depth=1, lasti=True), _ExceptionTableEntry(start=48, end=54, target=54, depth=0, lasti=False), ...]
co_positions = <sequenceiterator object at 0x0000000005b46668>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
310 0 NOP
311 2 LOAD_CONST 1 (0)
4 STORE_FAST 0 (z)
312 6 NOP
313 8 LOAD_CONST 2 ('x')
10 LOAD_CONST 3 (1)
12 BINARY_ADD
14 POP_TOP
16 LOAD_CONST 0 (None)
18 RETURN_VALUE
>> 20 PUSH_EXC_INFO
314 22 LOAD_GLOBAL 0 (TypeError)
32 STORE_FAST 0 (z)
316 34 LOAD_FAST 1 (e)
________________________ test_try_except_finally_nested ________________________
def test_try_except_finally_nested():
import dis
def run():
x = 5
try:
try:
if x > 2:
raise ValueError
finally:
x += 1
except ValueError:
x *= 7
return x
print()
> dis.dis(run)
../build/pypy/interpreter/test/apptest_exceptions.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'd\x01}\x00\t\x00\t\x00|\x00d\x02k\x04r\nt\x00\x82\x01|\x00d\x037\x00}\x00n\t#\x00|\x00d\x037\x00}\x00w\x00&\x03Y\x00w\x01n\x10#\x00t\x00$\x00r%\x01\x00|\x00d\x049\x00}\x00Y\x00n\x05w\x01w\x00&\x03Y\x00w\x01|\x00S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object run at 0x00007f43ac29c548, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exceptions.py", line 373>>
names = ('ValueError',), co_consts = (None, 5, 2, 1, 7)
linestarts = {0: 374, 4: 375, 6: 376, 8: 377, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=6, end=8, target=50, depth=0, lasti=False), _ExceptionTableEntry(start=8, end=20, target=3... end=48, target=50, depth=0, lasti=False), _ExceptionTableEntry(start=50, end=60, target=76, depth=1, lasti=True), ...]
co_positions = <sequenceiterator object at 0x00000000045564e8>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
374 0 LOAD_CONST 1 (5)
2 STORE_FAST 0 (x)
375 4 NOP
376 6 NOP
377 8 LOAD_FAST 0 (x)
10 LOAD_CONST 2 (2)
12 COMPARE_OP 4 (<)
378 16 LOAD_GLOBAL 0 (ValueError)
26 STORE_FAST 0 (x)
28 JUMP_FORWARD 9 (to 48)
>> 30 PUSH_EXC_INFO
32 LOAD_FAST 0 (x)
34 LOAD_CONST 3 (1)
36 INPLACE_ADD
38 STORE_FAST 0 (x)
____________________________ test_dis_try_except_as ____________________________
def test_dis_try_except_as():
print()
print("=== try/except T as name ===")
> dis.dis(_try_except_as)
../build/pypy/interpreter/test/apptest_exctable_dis.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00d\x01}\x00d\x00S\x00#\x00t\x00$\x00r\x14}\x01Y\x00d\x00}\x01~\x01d\x00S\x00d\x00}\x01~\x01w\x01w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _try_except_as at 0x00007f43ac29ce90, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 11>>
names = ('ValueError',), co_consts = (None, 1)
linestarts = {0: 12, 2: 13, 12: 14, 20: 15, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=6, target=10, depth=0, lasti=False), _ExceptionTableEntry(start=10, end=20, target=42, depth=1, lasti=True), _ExceptionTableEntry(start=32, end=42, target=42, depth=1, lasti=True)]
co_positions = <sequenceiterator object at 0x00007f43adf07160>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== try/except T as name ===
12 0 NOP
13 2 LOAD_CONST 1 (1)
4 STORE_FAST 0 (x)
6 LOAD_CONST 0 (None)
8 RETURN_VALUE
>> 10 PUSH_EXC_INFO
14 12 LOAD_GLOBAL 0 (ValueError)
22 LOAD_CONST 0 (None)
24 STORE_FAST 1 (e)
26 DELETE_FAST 1 (e)
28 LOAD_CONST 0 (None)
30 RETURN_VALUE
32 LOAD_CONST 0 (None)
34 STORE_FAST 1 (e)
36 DELETE_FAST 1 (e)
_________________________ test_dis_try_except_no_name __________________________
def test_dis_try_except_no_name():
print()
print("=== try/except T (no name) ===")
> dis.dis(_try_except_no_name)
../build/pypy/interpreter/test/apptest_exctable_dis.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00d\x01}\x00d\x00S\x00#\x00t\x00$\x00r\x0e\x01\x00Y\x00d\x00S\x00w\x01w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _try_except_no_name at 0x00007f43ac29cf98, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 18>>
names = ('ValueError',), co_consts = (None, 1)
linestarts = {0: 19, 2: 20, 12: 21, 20: 22, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=6, target=10, depth=0, lasti=False), _ExceptionTableEntry(start=10, end=20, target=30, depth=1, lasti=True), _ExceptionTableEntry(start=26, end=30, target=30, depth=1, lasti=True)]
co_positions = <sequenceiterator object at 0x00000000021c26e0>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== try/except T (no name) ===
19 0 NOP
20 2 LOAD_CONST 1 (1)
4 STORE_FAST 0 (x)
6 LOAD_CONST 0 (None)
8 RETURN_VALUE
>> 10 PUSH_EXC_INFO
21 12 LOAD_GLOBAL 0 (ValueError)
22 LOAD_CONST 0 (None)
24 RETURN_VALUE
__________________________ test_dis_try_except_multi ___________________________
def test_dis_try_except_multi():
print()
print("=== try/except with two handlers (both as name) ===")
> dis.dis(_try_except_multi_handler)
../build/pypy/interpreter/test/apptest_exctable_dis.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00d\x01}\x00d\x00S\x00#\x00t\x00$\x00r\x14}\x01Y\x00d\x00}\x01~\x01d\x00S\x00d\x00}\x01~\x01w\x01t\x01$\x00r"}\x01Y\x00d\x00}\x01~\x01d\x00S\x00d\x00}\x01~\x01w\x01w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _try_except_multi_handler at 0x00007f43ac29d0a0, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 25>>
names = ('TypeError', 'ValueError'), co_consts = (None, 1)
linestarts = {0: 26, 2: 27, 12: 28, 20: 29, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=6, target=10, depth=0, lasti=False), _ExceptionTableEntry(start=10, end=20, target=...rt=32, end=48, target=70, depth=1, lasti=True), _ExceptionTableEntry(start=60, end=70, target=70, depth=1, lasti=True)]
co_positions = <sequenceiterator object at 0x00007f43abe34ad0>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== try/except with two handlers (both as name) ===
26 0 NOP
27 2 LOAD_CONST 1 (1)
4 STORE_FAST 0 (x)
6 LOAD_CONST 0 (None)
8 RETURN_VALUE
>> 10 PUSH_EXC_INFO
28 12 LOAD_GLOBAL 0 (TypeError)
22 LOAD_CONST 0 (None)
24 STORE_FAST 1 (e)
26 DELETE_FAST 1 (e)
28 LOAD_CONST 0 (None)
30 RETURN_VALUE
32 LOAD_CONST 0 (None)
34 STORE_FAST 1 (e)
36 DELETE_FAST 1 (e)
_____________________________ test_dis_try_finally _____________________________
def test_dis_try_finally():
print()
print("=== try/finally ===")
> dis.dis(_try_finally)
../build/pypy/interpreter/test/apptest_exctable_dis.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00d\x01}\x00d\x00S\x00#\x00w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _try_finally at 0x00007f43ac29d1a8, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 34>>
names = (), co_consts = (None, 1), linestarts = {0: 35, 2: 36, 6: 38}
line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=6, target=10, depth=0, lasti=False), _ExceptionTableEntry(start=10, end=14, target=14, depth=1, lasti=True)]
co_positions = <sequenceiterator object at 0x000000000405f748>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== try/finally ===
35 0 NOP
36 2 LOAD_CONST 1 (1)
4 STORE_FAST 0 (x)
38 6 LOAD_CONST 0 (None)
8 RETURN_VALUE
>> 10 PUSH_EXC_INFO
_______________________________ test_dis_nested ________________________________
def test_dis_nested():
print()
print("=== nested try/except inside except handler ===")
> dis.dis(_nested_try_except_in_except)
../build/pypy/interpreter/test/apptest_exctable_dis.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00d\x01}\x00d\x00S\x00#\x00t\x00$\x00r \x01\x00\t\x00d\x02}\x01n\x0e#\x00t\x01$\x00r\x18\x01\x00Y\x00Y\x00d\x00S\x00w\x01w\x00&\x03Y\x00w\x01Y\x00d\x00S\x00w\x01w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _nested_try_except_in_except at 0x00007f43ac29d2b0, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 41>>
names = ('OSError', 'ValueError'), co_consts = (None, 1, 2)
linestarts = {0: 42, 2: 43, 12: 44, 20: 45, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=6, target=10, depth=0, lasti=False), _ExceptionTableEntry(start=10, end=20, target=..., end=28, target=62, depth=1, lasti=True), _ExceptionTableEntry(start=28, end=38, target=50, depth=2, lasti=True), ...]
co_positions = <sequenceiterator object at 0x00000000055fce90>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== nested try/except inside except handler ===
42 0 NOP
43 2 LOAD_CONST 1 (1)
4 STORE_FAST 0 (x)
6 LOAD_CONST 0 (None)
8 RETURN_VALUE
>> 10 PUSH_EXC_INFO
44 12 LOAD_GLOBAL 0 (OSError)
46 22 LOAD_CONST 2 (2)
24 STORE_FAST 1 (y)
26 JUMP_FORWARD 14 (to 56)
>> 28 PUSH_EXC_INFO
47 30 LOAD_GLOBAL 1 (NULL + OSError)
40 POP_EXCEPT
42 LOAD_CONST 0 (None)
44 RETURN_VALUE
_____________________________ test_dis_try_in_try ______________________________
def test_dis_try_in_try():
print()
print("=== nested try-in-try (settrace lineno test) ===")
> dis.dis(_try_in_try)
../build/pypy/interpreter/test/apptest_exctable_dis.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00\t\x00d\x00S\x00#\x00t\x00$\x00r\x13}\x00Y\x00d\x00}\x00~\x00d\x00S\x00d\x00}\x00~\x00w\x01w\x00&\x03Y\x00w\x01#\x00t\x00$\x00r \x01\x00Y\x00d\x00S\x00w\x01w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _try_in_try at 0x00007f43ac29d9e8, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 87>>
names = ('Exception',), co_consts = (None,)
linestarts = {0: 88, 2: 89, 4: 90, 10: 91, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=4, target=46, depth=0, lasti=False), _ExceptionTableEntry(start=8, end=18, target=4... end=46, target=46, depth=0, lasti=False), _ExceptionTableEntry(start=46, end=56, target=66, depth=1, lasti=True), ...]
co_positions = <sequenceiterator object at 0x0000000006cfa350>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== nested try-in-try (settrace lineno test) ===
88 0 NOP
89 2 NOP
90 4 LOAD_CONST 0 (None)
6 RETURN_VALUE
8 PUSH_EXC_INFO
91 10 LOAD_GLOBAL 0 (Exception)
20 LOAD_CONST 0 (None)
22 STORE_FAST 0 (ex)
24 DELETE_FAST 0 (ex)
26 LOAD_CONST 0 (None)
28 RETURN_VALUE
30 LOAD_CONST 0 (None)
32 STORE_FAST 0 (ex)
34 DELETE_FAST 0 (ex)
_______________________ test_except_star_cleanup_lineno ________________________
def test_except_star_cleanup_lineno():
# GH-101517 / pdb test: after the except* body runs, the RETURN_VALUE for
# the "all exceptions caught" path must be attributed to the except* clause
# line, not to the body line. pdb relies on this to display the right line.
import sys
print()
print("=== except* cleanup lineno dis ===")
> dis.dis(_except_star_all_caught)
../build/pypy/interpreter/test/apptest_exctable_dis.py:173:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\t\x00t\x00\x82\x01#\x00&\x01g\x00c\x02t\x01%\x00&\x01\x9a\x0b}\x00d\x00}\x00~\x00n\x07d\x00}\x00~\x00\x91\x03\x01\x00n\x01\x01\x00\x91\x01X\x00&\x01\x9e\x07\x01\x00Y\x00d\x00S\x00c\x02Y\x00w\x00c\x02Y\x00w\x00&\x03Y\x00w\x01'
varname_from_oparg = <bound method code._varname_from_oparg of <code object _except_star_all_caught at 0x00007f43ac122758, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_exctable_dis.py", line 158>>
names = ('KeyError', 'Exception'), co_consts = (None,)
linestarts = {0: 159, 2: 160, 8: 161, 24: 162, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=2, end=6, target=6, depth=0, lasti=False), _ExceptionTableEntry(start=6, end=24, target=74, depth=1, lasti=True), _ExceptionTableEntry(start=24, end=56, target=74, depth=1, lasti=True)]
co_positions = <sequenceiterator object at 0x0000000006ef31d8>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== except* cleanup lineno dis ===
159 0 NOP
160 2 LOAD_GLOBAL 0 (KeyError)
________________________ test_revert_exc_info_2_finally ________________________
def test_revert_exc_info_2_finally():
import sys, dis
def the_test():
assert sys.exc_info() == (None, None, None)
try:
try:
raise ValueError
finally:
try:
try:
raise IndexError
finally:
assert sys.exc_info()[0] is IndexError
except IndexError:
pass
assert sys.exc_info()[0] is ValueError
except ValueError:
pass
assert sys.exc_info() == (None, None, None)
> dis.dis(the_test)
../build/pypy/interpreter/test/apptest_raise.py:101:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\x89\x00j\x00}\x00|\x00\x83\x00}\x01d\x01}\x02|\x01|\x02k\x02}\x03|\x03sFt\x01\xa0\x02d\x02|\x03f\x01d\x03|\x01|\x02...x16\x00}\x05t\x07t\x01\xa0\x08|\x05\xa1\x01\x83\x01\x82\x01d\x00\x08\x00}\x00\x08\x00}\x01\x08\x00}\x03}\x02d\x00S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object the_test at 0x00007f43ac4dde08, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_raise.py", line 83>>
names = ('exc_info', '@pytest_ar', '_call_reprcompare', '@py_builtins', 'locals', '_should_repr_global_name', ...)
co_consts = (None, (None, None, None), ('==',), ('%(py4)s\n{%(py4)s = %(py2)s\n{%(py2)s = %(py0)s.exc_info\n}()\n} == %(py7)s',), 'sys', ('py0', 'py2', 'py4', 'py7'), ...)
linestarts = {0: 84, 156: 85, 158: 86, 160: 87, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=158, end=160, target=472, depth=0, lasti=False), _ExceptionTableEntry(start=160, end=164, ...174, target=174, depth=2, lasti=False), _ExceptionTableEntry(start=174, end=306, target=306, depth=3, lasti=True), ...]
co_positions = <sequenceiterator object at 0x0000000007210890>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
84 0 LOAD_DEREF 0 (@py_assert1)
2 LOAD_ATTR 0 (exc_info)
22 STORE_FAST 3 (@py_assert5)
24 LOAD_FAST 3 (@py_assert5)
26 POP_JUMP_IF_TRUE 70 (to 140)
28 LOAD_GLOBAL 1 (NULL + exc_info)
38 LOAD_CONST 3 (('%(py4)s\n{%(py4)s = %(py2)s\n{%(py2)s = %(py0)s.exc_info\n}()\n} == %(py7)s',))
40 LOAD_FAST 1 (@py_assert3)
42 LOAD_FAST 2 (@py_assert6)
_____________________________ test_with_reraise_2 ______________________________
def test_with_reraise_2():
import dis
class Context:
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, exc_tb):
return True
def the_test():
def fn():
try:
raise ValueError("foo")
except:
with Context():
raise KeyError("caught")
raise
with pytest.raises(ValueError):
fn()
> dis.dis(the_test)
../build/pypy/interpreter/test/apptest_raise.py:222:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'\x88\x00f\x01d\x01\x84\x08}\x00t\x00\xa0\x01t\x02\xa1\x015\x00\x01\x00|\x00\x83\x00\x01\x00d\x00\x08\x00\x08\x00\x83\x03\x01\x00d\x00S\x00#\x001\x00s\x1cw\x02&\x03Y\x00w\x01\x01\x00Y\x00\x01\x00\x01\x00d\x00S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object the_test at 0x00000000015693b8, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_raise.py", line 211>>
names = ('pytest', 'raises', 'ValueError')
co_consts = (None, <code object fn at 0x00000000015692b0, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_raise.py", line 212>)
linestarts = {0: 212, 10: 219, 22: 220, 28: 219}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=20, end=28, target=42, depth=1, lasti=True), _ExceptionTableEntry(start=42, end=50, target=50, depth=3, lasti=True), _ExceptionTableEntry(start=56, end=58, target=50, depth=3, lasti=True)]
co_positions = <sequenceiterator object at 0x00000000051d9490>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
212 0 LOAD_CLOSURE 0 (fn)
_________________ test_traceback_positions_trailing_whitespace _________________
def test_traceback_positions_trailing_whitespace():
# issue gh-5219
def name_error():
# note this has excess trailing whitespace
a = b
with raises(NameError) as exc_info:
name_error()
original_std_err = sys.stderr
sys.stderr = buffer = Buffer()
original_exc_format = sys.excepthook(
exc_info.type, exc_info.value, exc_info.value.__traceback__
)
sys.stderr = original_exc_format
expected_exc_format = [
' a = b',
' ^',
"NameError: name 'b' is not defined"
]
> assert buffer.get_lines()[-3:] == expected_exc_format
E AssertionError: assert [' a = b',... not defined'] == [' a = b',... not defined']
E At index 1 diff: ' ^' != ' ^'
E Use -v to get the full diff
../build/pypy/interpreter/test/apptest_traceback.py:121: AssertionError
___________________________ test_colors_in_traceback ___________________________
def test_colors_in_traceback():
import os
def division_by_zero(a, b):
return (
a + b / 0 # abc
)
old_value = os.environ.get('FORCE_COLOR', None)
os.environ['FORCE_COLOR'] = '1'
try:
from _colorize import can_colorize, ANSIColors
assert can_colorize()
with raises(ZeroDivisionError) as exc_info:
division_by_zero(1, 2)
original_std_err = sys.stderr
sys.stderr = buffer = Buffer()
original_exc_format = sys.excepthook(
exc_info.type, exc_info.value, exc_info.value.__traceback__
)
sys.stderr = original_std_err
expected_exc_format = [
f' a + {ANSIColors.BOLD_RED}b / 0{ANSIColors.RESET} # abc',
f' {ANSIColors.BOLD_RED}~~^~~{ANSIColors.RESET}',
f'{ANSIColors.BOLD_MAGENTA}ZeroDivisionError{ANSIColors.RESET}: {ANSIColors.MAGENTA}division by zero{ANSIColors.RESET}'
]
> assert buffer.get_lines()[-3:] == expected_exc_format
E AssertionError: assert [' a ...sion by zero'] == [' a ... zero\x1b[0m']
E At index 0 diff: ' a + b / 0 # abc' != ' a + \x1b[1;31mb / 0\x1b[0m # abc'
E Use -v to get the full diff
../build/pypy/interpreter/test/apptest_traceback.py:192: AssertionError
_____________________________ test_shutil_pattern ______________________________
def test_shutil_pattern():
# Reproduce the shutil.copyfile failure.
# Multiple early returns inside the inner with cause duplicate_exits_without_lineno
# to copy the with-exit code, which confuses the linear exception table scan and
# leaves the fallback path (copyfileobj) with no exception table coverage.
# Structure mirrors shutil.copyfile:
# outer with (suppresses) -> try/except -> inner with (raises in __exit__)
# -> fast paths with early returns -> fallback that raises via None return
class InnerCM:
def __enter__(self):
return None # intentional -- fallback body raises AttributeError
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is not None:
raise OSError("dest close failed")
return False
class OuterCM:
exited_with = 'not called'
def __enter__(self): return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.exited_with = exc_type
return True # suppress everything
class GiveupOnFastCopy(Exception):
pass
def copyfile(use_fast1, use_fast2):
result = []
outer = OuterCM()
with outer:
try:
with InnerCM() as f:
if use_fast1:
try:
result.append('fast1')
return result
except GiveupOnFastCopy:
pass
elif use_fast2:
try:
result.append('fast2')
return result
except GiveupOnFastCopy:
pass
# fallback: f is None, raises AttributeError
result.append(f.read)
except IsADirectoryError:
pass
return outer
import dis
> dis.dis(copyfile)
../build/pypy/interpreter/test/apptest_with_leak.py:131:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b"g\x00}\x02\x89\x02\x83\x00}\x03|\x035\x00\x01\x00\t\x00\x89\x01\x83\x005\x00}\x04|\x00r/\t\x00|\x02\xa0\x00d\x01\xa1...\x00\x08\x00\x08\x00\x83\x03\x01\x00\x99\x86#\x001\x00s\x82w\x02&\x03Y\x00w\x01\x01\x00Y\x00\x01\x00\x01\x00|\x03S\x00"
varname_from_oparg = <bound method code._varname_from_oparg of <code object copyfile at 0x00007f43ae93bd00, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_with_leak.py", line 106>>
names = ('append', 'read', 'IsADirectoryError')
co_consts = (None, 'fast1', 'fast2')
linestarts = {0: 107, 4: 108, 10: 109, 16: 110, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=14, end=18, target=246, depth=1, lasti=True), _ExceptionTableEntry(start=18, end=24, targe...end=56, target=210, depth=1, lasti=False), _ExceptionTableEntry(start=70, end=80, target=88, depth=3, lasti=True), ...]
co_positions = <sequenceiterator object at 0x0000000002483898>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
___________________ test_lru_cache_style_with_lock_exception ___________________
def test_lru_cache_style_with_lock_exception():
# Reproduces WITH_EXCEPT_START crash: a wrapper using 'with lock:' around a
# cache lookup where the wrapped function raises between the two with-blocks.
import dis
from _thread import RLock
def make_cached(user_function):
cache = {}
lock = RLock()
def wrapper(*args):
key = args
with lock:
if key in cache:
return cache[key]
result = user_function(*args)
with lock:
cache[key] = result
return result
return wrapper
@make_cached
def func(i):
return 'abc'[i]
> dis.dis(func) # dis the wrapper to aid debugging
../build/pypy/interpreter/test/apptest_with_leak.py:170:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'|\x00}\x01\x89\x015\x00\x01\x00|\x01\x89\x00v\x00r\x13\x89\x00|\x01\x19\x00\x06\x00d\x00\x08\x00\x08\x00\x83\x03\x01...<\x00d\x00\x08\x00\x08\x00\x83\x03\x01\x00\x99@#\x001\x00s<w\x02&\x03Y\x00w\x01\x01\x00Y\x00\x01\x00\x01\x00|\x02S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object wrapper at 0x00007f43ad308128, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_with_leak.py", line 154>>
names = (), co_consts = (None,)
linestarts = {0: 155, 4: 156, 10: 157, 18: 158, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=8, end=24, target=50, depth=1, lasti=True), _ExceptionTableEntry(start=50, end=58, target=..., end=114, target=114, depth=3, lasti=True), _ExceptionTableEntry(start=120, end=122, target=114, depth=3, lasti=True)]
co_positions = <sequenceiterator object at 0x00007f43afc5bd30>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
155 0 LOAD_FAST 0 (args)
2 STORE_FAST 1 (key)
156 4 LOAD_DEREF 1 (key)
6 BEFORE_WITH
8 POP_TOP
157 10 LOAD_FAST 1 (key)
12 LOAD_DEREF 0 (args)
_____________________ test_lru_cache_exception_no_context ______________________
def test_lru_cache_exception_no_context():
# test_functools.TestLRU.test_lru_with_exceptions: exception raised between
# the two 'with lock:' blocks must not gain __context__ from lock cleanup.
import dis
from _thread import RLock
def make_cached(user_function):
cache = {}
lock = RLock()
def wrapper(*args):
key = args
with lock:
if key in cache:
return cache[key]
result = user_function(*args)
with lock:
cache[key] = result
return result
return wrapper
@make_cached
def func(i):
return 'abc'[i]
print("\n=== apptest double-with wrapper dis ===")
> dis.dis(func)
../build/pypy/interpreter/test/apptest_with_leak.py:208:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'|\x00}\x01\x89\x015\x00\x01\x00|\x01\x89\x00v\x00r\x13\x89\x00|\x01\x19\x00\x06\x00d\x00\x08\x00\x08\x00\x83\x03\x01...<\x00d\x00\x08\x00\x08\x00\x83\x03\x01\x00\x99@#\x001\x00s<w\x02&\x03Y\x00w\x01\x01\x00Y\x00\x01\x00\x01\x00|\x02S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object wrapper at 0x00007f43acb96230, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_with_leak.py", line 191>>
names = (), co_consts = (None,)
linestarts = {0: 192, 4: 193, 10: 194, 18: 195, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=8, end=24, target=50, depth=1, lasti=True), _ExceptionTableEntry(start=50, end=58, target=..., end=114, target=114, depth=3, lasti=True), _ExceptionTableEntry(start=120, end=122, target=114, depth=3, lasti=True)]
co_positions = <sequenceiterator object at 0x0000000006c934c0>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== apptest double-with wrapper dis ===
192 0 LOAD_FAST 0 (args)
2 STORE_FAST 1 (key)
193 4 LOAD_DEREF 1 (key)
6 BEFORE_WITH
8 POP_TOP
194 10 LOAD_FAST 1 (key)
12 LOAD_DEREF 0 (args)
_________________ test_except_pass_around_lru_style_exception __________________
def test_except_pass_around_lru_style_exception():
# typing.py inner() pattern: try: return cached(...) except TypeError: pass
# then raise ValueError. The ValueError must have no __context__ from the
# suppressed TypeError caught inside the two-with-lock wrapper.
import dis
from _thread import RLock
def make_cached(user_function):
cache = {}
lock = RLock()
def wrapper(*args):
key = args
with lock:
if key in cache:
return cache[key]
result = user_function(*args)
with lock:
cache[key] = result
return result
return wrapper
@make_cached
def cached(x):
if x < 0:
raise TypeError("bad arg")
return x
def inner(x):
try:
return cached(x)
except TypeError:
pass
raise ValueError("fallback error")
print("\n=== apptest cached wrapper dis ===")
> dis.dis(cached)
../build/pypy/interpreter/test/apptest_with_leak.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/dis.py:114: in dis
_disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:555: in _disassemble_recursive
disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
../build/lib-python/3/dis.py:548: in disassemble
_disassemble_bytes(_get_code_array(co, adaptive),
../build/lib-python/3/dis.py:586: in _disassemble_bytes
for instr in _get_instructions_bytes(code, varname_from_oparg, names,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = b'|\x00}\x01\x89\x015\x00\x01\x00|\x01\x89\x00v\x00r\x13\x89\x00|\x01\x19\x00\x06\x00d\x00\x08\x00\x08\x00\x83\x03\x01...<\x00d\x00\x08\x00\x08\x00\x83\x03\x01\x00\x99@#\x001\x00s<w\x02&\x03Y\x00w\x01\x01\x00Y\x00\x01\x00\x01\x00|\x02S\x00'
varname_from_oparg = <bound method code._varname_from_oparg of <code object wrapper at 0x00007f43acb971a8, file "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/interpreter/test/apptest_with_leak.py", line 239>>
names = (), co_consts = (None,)
linestarts = {0: 240, 4: 241, 10: 242, 18: 243, ...}, line_offset = 0
exception_entries = [_ExceptionTableEntry(start=8, end=24, target=50, depth=1, lasti=True), _ExceptionTableEntry(start=50, end=58, target=..., end=114, target=114, depth=3, lasti=True), _ExceptionTableEntry(start=120, end=122, target=114, depth=3, lasti=True)]
co_positions = <sequenceiterator object at 0x000000000728d250>
show_caches = False
def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
linestarts=None, line_offset=0,
exception_entries=(), co_positions=None,
show_caches=False):
"""Iterate over the instructions in a bytecode string.
Generates a sequence of Instruction namedtuples giving the details of each
opcode. Additional information about the code's runtime environment
(e.g. variable names, co_consts) can be specified using optional
arguments.
"""
co_positions = co_positions or iter(())
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
if starts_line is not None:
starts_line += line_offset
is_jump_target = offset in labels
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = _deoptop(op)
caches = _inline_cache_entries[deop]
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
argval = arg*2
argrepr = "to " + repr(argval)
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
argval += 2 * caches
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
elif deop in hascompare:
argval = cmp_op[arg>>4]
argrepr = argval
elif deop == FORMAT_VALUE:
argval, argrepr = FORMAT_VALUE_CONVERTERS[arg & 0x3]
argval = (argval, bool(arg & 0x4))
if argval[1]:
if argrepr:
argrepr += ', '
argrepr += 'with format'
elif deop == MAKE_FUNCTION:
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
if arg & (1<<i))
> elif deop == BINARY_OP:
E NameError: name 'BINARY_OP' is not defined
../build/lib-python/3/dis.py:512: NameError
----------------------------- Captured stdout call -----------------------------
=== apptest cached wrapper dis ===
240 0 LOAD_FAST 0 (args)
2 STORE_FAST 1 (key)
241 4 LOAD_DEREF 1 (key)
6 BEFORE_WITH
8 POP_TOP
242 10 LOAD_FAST 1 (key)
12 LOAD_DEREF 0 (args)
________________________________ test_function _________________________________
def test_function():
for method, args in (
({1, 2}.__contains__, (2,)),
(set.__contains__, ({1, 2}, 2)),
):
for proto in protocols:
data = dumps(method, proto)
pydata = dumps_py(method, proto)
> assert data == pydata
E AssertionError: assert b'\x80\x03cbu...6q\x03Rq\x04.' == b'\x80\x03cbu...01\x86Rq\x02.'
E At index 36 diff: b'q' != b'X'
E Use -v to get the full diff
../build/pypy/module/_pickle/test/apptest_pickle.py:383: AssertionError
_______________________________ test_signatures ________________________________
@pytest.mark.skipif(not hasattr(sys, 'pypy_translation_info'), reason='requires translated PyPy')
def test_signatures():
import inspect
assert str(inspect.signature(math.factorial)) == '(n, /)'
assert str(inspect.signature(math.isqrt)) == '(n, /)'
> assert str(inspect.signature(math.gcd)) == '(*integers)'
../build/pypy/module/math/test/apptest_math.py:186:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib-python/3/inspect.py:3348: in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
../build/lib-python/3/inspect.py:3085: in from_callable
return _signature_from_callable(obj, sigcls=cls,
../build/lib-python/3/inspect.py:2602: in _signature_from_callable
return _signature_from_builtin(sigcls, obj,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'inspect.Signature'>, func = <built-in function gcd>
skip_bound_arg = True
def _signature_from_builtin(cls, func, skip_bound_arg=True):
"""Private helper function to get signature for
builtin callables.
"""
if not _signature_is_builtin(func):
raise TypeError("{!r} is not a Python builtin "
"function".format(func))
s = getattr(func, "__text_signature__", None)
if not s:
> raise ValueError("no signature found for builtin {!r}".format(func))
E ValueError: no signature found for builtin <built-in function gcd>
../build/lib-python/3/inspect.py:2392: ValueError
=============================== warnings summary ===============================
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:689: 25 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:689: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
and isinstance(item.value, ast.Str)
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:691: 25 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:691: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
doc = item.value.s
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:958: 7086 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:958: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
inlocs = ast.Compare(ast.Str(name.id), [ast.In()], [locs])
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:961: 7086 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:961: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
expr = ast.IfExp(test, self.display(name), ast.Str(name.id))
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:1071: 4728 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:1071: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
syms.append(ast.Str(sym))
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:1073: 4728 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:1073: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
expls.append(ast.Str(expl))
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:823: 25835 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:823: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
keys = [ast.Str(key) for key in current.keys()]
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:933: 5022 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:933: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
assertmsg = ast.Str("")
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:935: 5163 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:935: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
template = ast.BinOp(assertmsg, ast.Add(), ast.Str(explanation))
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:947: 5149 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:947: DeprecationWarning: ast.NameConstant is deprecated and will be removed in Python 3.14; use ast.Constant instead
clear = ast.Assign(variables, ast.NameConstant(None))
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:983: 97 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:983: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
expl_format = self.pop_format_context(ast.Str(expl))
pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:995: 48 warnings
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/assertion/rewrite.py:995: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
expl_template = self.helper("_format_boolop", expl_list, ast.Num(is_or))
../build/pypy/objspace/std/test/apptest_unicode.py:650
/build_dir/pypy-c-jit-linux-x86-64/build/pypy/objspace/std/test/apptest_unicode.py:650: SyntaxWarning: invalid escape sequence '\?'
('\?', b'+AFw?'),
pypy/module/_sre/test/apptest_sre.py::test_magic
/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/_sre/test/apptest_sre.py:54: DeprecationWarning: module 'sre_constants' is deprecated
import _sre, sre_constants
pypy/module/_sre/test/apptest_sre.py::test_no_pattern
/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/_sre/test/apptest_sre.py:271: DeprecationWarning: module 'sre_compile' is deprecated
import sre_compile, sre_parse
pypy/module/_sre/test/apptest_sre.py::test_no_pattern
/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/_sre/test/apptest_sre.py:271: DeprecationWarning: module 'sre_parse' is deprecated
import sre_compile, sre_parse
pypy/module/_warnings/test/apptest_warnings.py::test_defaults
/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/_warnings/test/apptest_warnings.py:20: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources
pypy/module/_weakref/test/apptest_weakref.py::test_buggy_case
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: : <function test_buggy_case.<locals>.A.__del__ at 0x0000000006c79150>
TypeError: test_buggy_case.<locals>.A.__del__() takes 0 positional arguments but 1 was given
warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
pypy/module/_weakref/test/apptest_weakref.py::test_callback_raises
/build_dir/pypy-c-jit-linux-x86-64/venv/pypy-venv/lib/pypy3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: weakref callback : <function test_callback_raises.<locals>.callback at 0x0000000006b72408>
Traceback (most recent call last):
File "/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/_weakref/test/apptest_weakref.py", line 498, in callback
explode
NameError: name 'explode' is not defined
warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
-- Docs: https://docs.pytest.org/en/stable/warnings.html
---- generated xml file: /build_dir/pypy-c-jit-linux-x86-64/venv/test-D.log ----
=========================== short test summary info ============================
FAILED ../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py::test_with_try_except_as_reraise
FAILED ../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py::test_except_star_cleanup_lineno
FAILED ../build/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py::test_except_star_trace_return_lineno
FAILED ../build/pypy/interpreter/astcompiler/test/apptest_patma.py::test_match_mapping_codegen_uses_unpack_sequence
FAILED ../build/pypy/interpreter/pyparser/test/apptest_parsestring.py::test_invalid_escape_syntax_error_span
FAILED ../build/pypy/interpreter/test/apptest_exceptions.py::test_nested_except_raise_stored
FAILED ../build/pypy/interpreter/test/apptest_exceptions.py::test_try_except_finally_nested
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_dis_try_except_as
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_dis_try_except_no_name
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_dis_try_except_multi
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_dis_try_finally
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_dis_nested
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_dis_try_in_try
FAILED ../build/pypy/interpreter/test/apptest_exctable_dis.py::test_except_star_cleanup_lineno
FAILED ../build/pypy/interpreter/test/apptest_raise.py::test_revert_exc_info_2_finally
FAILED ../build/pypy/interpreter/test/apptest_raise.py::test_with_reraise_2
FAILED ../build/pypy/interpreter/test/apptest_traceback.py::test_traceback_positions_trailing_whitespace
FAILED ../build/pypy/interpreter/test/apptest_traceback.py::test_colors_in_traceback
FAILED ../build/pypy/interpreter/test/apptest_with_leak.py::test_shutil_pattern
FAILED ../build/pypy/interpreter/test/apptest_with_leak.py::test_lru_cache_style_with_lock_exception
FAILED ../build/pypy/interpreter/test/apptest_with_leak.py::test_lru_cache_exception_no_context
FAILED ../build/pypy/interpreter/test/apptest_with_leak.py::test_except_pass_around_lru_style_exception
FAILED ../build/pypy/module/_pickle/test/apptest_pickle.py::test_function - A...
FAILED ../build/pypy/module/math/test/apptest_math.py::test_signatures - Valu...
========= 24 failed, 2013 passed, 18 skipped, 64999 warnings in 38.63s =========
program finished with exit code 1
elapsedTime=40.248854