Home - Summaries: (main) : (py3.11) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

pypy/interpreter/test/test_compiler.py::AppTestOptimizer::()::test_folding_of_binops_on_constants

self = <CallInfo when='call' exception: Subprocess failed with exit code 1:
Traceback (most recent call last):
  File "/tmp/p...s
    elif deop == LOAD_SUPER_ATTR:
                 ^^^^^^^^^^^^^^^
NameError: name 'LOAD_SUPER_ATTR' is not defined
>
func = <function <lambda> at 0x7f84f9d3f3d0>, when = 'call'

    def __init__(self, func, when):
        #: context of invocation: one of "setup", "call",
        #: "teardown", "memocollect"
        self.when = when
        self.start = time()
        try:
>           self.result = func()

../_pytest/runner.py:150: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   return CallInfo(lambda: ihook(item=item, **kwds), when=when)

../_pytest/runner.py:138: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_HookCaller 'pytest_runtest_call'>
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_folding_of_binops_on_constants'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_folding_of_binops_on_constants'>}

    def __call__(self, **kwargs):
        assert not self.is_historic()
>       return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)

../_pytest/vendored_packages/pluggy.py:724: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.config.PytestPluginManager object at 0x7f84fe878f50>
hook = <_HookCaller 'pytest_runtest_call'>, methods = []
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_folding_of_binops_on_constants'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_folding_of_binops_on_constants'>}

    def _hookexec(self, hook, methods, kwargs):
        # called from all hookcaller instances.
        # enable_tracing will set its own wrapping function at self._inner_hookexec
>       return self._inner_hookexec(hook, methods, kwargs)

../_pytest/vendored_packages/pluggy.py:338: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

hook = <_HookCaller 'pytest_runtest_call'>, methods = []
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_folding_of_binops_on_constants'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_folding_of_binops_on_constants'>}

    self._inner_hookexec = lambda hook, methods, kwargs: \
>       _MultiCall(methods, kwargs, hook.spec_opts).execute()

../_pytest/vendored_packages/pluggy.py:333: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_folding_of_binops_on_constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>

    def execute(self):
        all_kwargs = self.kwargs
        self.results = results = []
        firstresult = self.specopts.get("firstresult")
    
        while self.hook_impls:
            hook_impl = self.hook_impls.pop()
            args = [all_kwargs[argname] for argname in hook_impl.argnames]
            if hook_impl.hookwrapper:
>               return _wrapped_call(hook_impl.function(*args), self.execute)

../_pytest/vendored_packages/pluggy.py:595: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

wrap_controller = <generator object pytest_runtest_call at 0x7f84f9ea1780>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>

    def _wrapped_call(wrap_controller, func):
        """ Wrap calling to a function with a generator which needs to yield
        exactly once.  The yield point will trigger calling the wrapped function
        and return its _CallOutcome to the yield point.  The generator then needs
        to finish (raise StopIteration) in order for the wrapped call to complete.
        """
        try:
            next(wrap_controller)   # first yield
        except StopIteration:
            _raise_wrapfail(wrap_controller, "did not yield")
        call_outcome = _CallOutcome(func)
        try:
            wrap_controller.send(call_outcome)
            _raise_wrapfail(wrap_controller, "has second yield")
        except StopIteration:
            pass
>       return call_outcome.get_result()

../_pytest/vendored_packages/pluggy.py:253: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x7f84f9d96b90>

    def get_result(self):
        if self.excinfo is None:
            return self.result
        else:
            ex = self.excinfo
            if _py3:
                raise ex[1].with_traceback(ex[2])
>           _reraise(*ex)  # noqa

../_pytest/vendored_packages/pluggy.py:279: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x7f84f9d96b90>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>

    def __init__(self, func):
        try:
>           self.result = func()

../_pytest/vendored_packages/pluggy.py:264: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_folding_of_binops_on_constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>

    def execute(self):
        all_kwargs = self.kwargs
        self.results = results = []
        firstresult = self.specopts.get("firstresult")
    
        while self.hook_impls:
            hook_impl = self.hook_impls.pop()
            args = [all_kwargs[argname] for argname in hook_impl.argnames]
            if hook_impl.hookwrapper:
>               return _wrapped_call(hook_impl.function(*args), self.execute)

../_pytest/vendored_packages/pluggy.py:595: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

wrap_controller = <generator object pytest_runtest_call at 0x7f84f9d96f00>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>

    def _wrapped_call(wrap_controller, func):
        """ Wrap calling to a function with a generator which needs to yield
        exactly once.  The yield point will trigger calling the wrapped function
        and return its _CallOutcome to the yield point.  The generator then needs
        to finish (raise StopIteration) in order for the wrapped call to complete.
        """
        try:
            next(wrap_controller)   # first yield
        except StopIteration:
            _raise_wrapfail(wrap_controller, "did not yield")
        call_outcome = _CallOutcome(func)
        try:
            wrap_controller.send(call_outcome)
            _raise_wrapfail(wrap_controller, "has second yield")
        except StopIteration:
            pass
>       return call_outcome.get_result()

../_pytest/vendored_packages/pluggy.py:253: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x7f84fa085190>

    def get_result(self):
        if self.excinfo is None:
            return self.result
        else:
            ex = self.excinfo
            if _py3:
                raise ex[1].with_traceback(ex[2])
>           _reraise(*ex)  # noqa

../_pytest/vendored_packages/pluggy.py:279: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x7f84fa085190>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>

    def __init__(self, func):
        try:
>           self.result = func()

../_pytest/vendored_packages/pluggy.py:264: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_folding_of_binops_on_constants'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>

    def execute(self):
        all_kwargs = self.kwargs
        self.results = results = []
        firstresult = self.specopts.get("firstresult")
    
        while self.hook_impls:
            hook_impl = self.hook_impls.pop()
            args = [all_kwargs[argname] for argname in hook_impl.argnames]
            if hook_impl.hookwrapper:
                return _wrapped_call(hook_impl.function(*args), self.execute)
>           res = hook_impl.function(*args)

../_pytest/vendored_packages/pluggy.py:596: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

item = <AppTestMethod 'test_folding_of_binops_on_constants'>

    def pytest_runtest_call(item):
        try:
>           item.runtest()

../_pytest/runner.py:91: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <AppTestMethod 'test_folding_of_binops_on_constants'>

    def runtest(self):
        target = self.obj
        src = extract_docstring_if_empty_function(target.im_func)
        space = target.im_self.space
        if self.config.option.runappdirect:
            appexec_definitions = self.parent.obj.__dict__
            spaceconfig = getattr(self.parent.obj, 'spaceconfig', None)
            usemodules = spaceconfig.get('usemodules') if spaceconfig else None
            return run_with_python(self.config.option.python, src, usemodules,
>                                  **appexec_definitions)

tool/pytest/apptest.py:327: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

python_ = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/goal/pypy3.12-c'
target_ = <function test_folding_of_binops_on_constants at 0x7f84faade2d0>
usemodules = None
definitions = {'is_pypy': <bound method AppTestOptimizer.w_is_pypy of <pypy.interpreter.test.test_compiler.AppTestOptimizer object at 0x7f84f9d3aa10>>, 'runappdirect': True}
defs = ["def w_is_pypy(self):\n    import sys\n    return not self.runappdirect or '__pypy__' in sys.modules", 'type(self).is_pypy = w_is_pypy\n', 'self.runappdirect = True\n']
symbol = 'runappdirect', value = True
code = <py._code.code.Code object at 0x7f84f9d3afd0>

    def run_with_python(python_, target_, usemodules, **definitions):
        if python_ is None:
            py.test.skip("Cannot find the default python3 interpreter to run with -A")
        defs = []
        for symbol, value in sorted(definitions.items()):
            if isinstance(value, tuple) and isinstance(value[0], py.code.Source):
                code, args = value
                defs.append(str(code))
                arg_repr = []
                for arg in args:
                    if isinstance(arg, types.FunctionType):
                        arg_repr.append(arg.__name__)
                    elif isinstance(arg, types.MethodType):
                        arg_repr.append(arg.__name__)
                    else:
                        arg_repr.append(py3k_repr(arg))
                args = ', '.join(arg_repr)
                defs.append("self.%s = anonymous(%s)\n" % (symbol, args))
            elif isinstance(value, types.MethodType):
                # "def w_method(self)"
                code = py.code.Code(value)
                defs.append(str(code.source()))
                defs.append("type(self).%s = %s\n" % (symbol, value.__name__))
            elif isinstance(value, types.ModuleType):
                name = value.__name__
                defs.append("import %s; self.%s = %s\n" % (name, symbol, name))
            elif isinstance(value, (str, unicode, int, long, float, list, tuple,
                                    dict)) or value is None:
                defs.append("self.%s = %s\n" % (symbol, py3k_repr(value)))
    
        check_usemodules = ''
        if usemodules:
            usemodules = [_rename_module(name) for name in usemodules]
            check_usemodules = """\
        missing = set(%r).difference(sys.builtin_module_names)
        if missing:
            if not hasattr(sys, 'pypy_version_info'):
                # They may be extension modules on CPython
                name = None
                for name in missing.copy():
                    if name in ['cpyext', '_cffi_backend', '_rawffi']:
                        missing.remove(name)
                        continue
                    try:
                        __import__(name)
                    except ImportError:
                        pass
                    else:
                        missing.remove(name)
                del name
            if missing:
                sys.exit(81)
        del missing""" % usemodules
    
        source = list(py.code.Source(target_))
        while source[0].startswith(('@py.test.mark.', '@pytest.mark.')):
            source.pop(0)
        source = source[1:]
    
        pyfile = udir.join('src.py')
        if isinstance(target_, str):
            # Special case of a docstring; the function name is the first word.
            target_name = target_.split('(', 1)[0]
        else:
            target_name = target_.__name__
        with pyfile.open('w') as f:
            f.write(helpers % (pypyroot, check_usemodules))
            f.write('\n'.join(defs))
            f.write('def %s():\n' % target_name)
            f.write('\n'.join(source))
            f.write("\ntry:\n    %s()\n" % target_name)
            f.write('finally:\n    print("===aefwuiheawiu===")')
        helper_dir = os.path.join(pypydir, 'tool', 'cpyext')
        env = os.environ.copy()
        env['PYTHONPATH'] = helper_dir
        res, stdout, stderr = run_subprocess(
            python_, [str(pyfile)], env=env)
        print pyfile.read()
        print "from", str(pyfile)
        print >> sys.stdout, stdout
        print >> sys.stderr, stderr
        if res == 81:
            py.test.skip('%r was not compiled w/ required usemodules: %r' %
                         (python_, usemodules))
        elif res != 0:
            raise AssertionError(
>               "Subprocess failed with exit code %s:\n%s" % (res, stderr))
E           AssertionError: Subprocess failed with exit code 1:
E           Traceback (most recent call last):
E             File "/tmp/pytest/usession-py3.12-1450/src.py", line 109, in <module>
E               test_folding_of_binops_on_constants()
E             File "/tmp/pytest/usession-py3.12-1450/src.py", line 95, in test_folding_of_binops_on_constants
E               asm = dis_single(line)
E                     ^^^^^^^^^^^^^^^^
E             File "/tmp/pytest/usession-py3.12-1450/src.py", line 76, in dis_single
E               return disassemble(compile(line, '', 'single'))
E                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E             File "/tmp/pytest/usession-py3.12-1450/src.py", line 69, in disassemble
E               dis.dis(func)
E                   ^^^
E             File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 114, in dis
E               _disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
E             File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 555, in _disassemble_recursive
E               disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
E             File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 548, in disassemble
E               _disassemble_bytes(_get_code_array(co, adaptive),
E             File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 586, in _disassemble_bytes
E               for instr in _get_instructions_bytes(code, varname_from_oparg, names,
E             File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 483, in _get_instructions_bytes
E               elif deop == LOAD_SUPER_ATTR:
E                            ^^^^^^^^^^^^^^^
E           NameError: name 'LOAD_SUPER_ATTR' is not defined

tool/pytest/apptest.py:239: AssertionError
---------- Captured stdout call ----------
# -*- encoding: utf-8 -*-
if 1:
    import sys
    sys.path.append('/build_dir/pypy-c-jit-linux-x86-64/build')

    def skip(message):
        print(message)
        raise SystemExit(0)
    __builtins__.skip = skip
    __builtins__.py3k_skip = skip
    class ExceptionWrapper:
        pass
    def raises(exc, *args, **kwargs):
        if not args:
            return RaisesContext(exc)
        func = args[0]
        args = args[1:]
        import os
        try:
            if isinstance(func, str):
                if func.startswith((' ', os.linesep, '\n')):
                    # it's probably an indented block, so we prefix if True:
                    # to avoid SyntaxError
                    func = "if True:\n" + func
                frame = sys._getframe(1)
                exec(func, frame.f_globals, frame.f_locals)
            else:
                func(*args, **kwargs)
        except exc as e:
            res = ExceptionWrapper()
            res.value = e
            res.traceback = e.__traceback__
            return res
        else:
            raise AssertionError("DID NOT RAISE")

    class RaisesContext(object):
        def __init__(self, expected_exception):
            self.expected_exception = expected_exception
            self.excinfo = None

        def __enter__(self):
            return self

        def __exit__(self, *tp):
            __tracebackhide__ = True
            if tp[0] is None:
                raise AssertionError("DID NOT RAISE")
            self.value = tp[1]
            return issubclass(tp[0], self.expected_exception)

    __builtins__.raises = raises
    class Test:
        pass
    self = Test()
def w_is_pypy(self):
    import sys
    return not self.runappdirect or '__pypy__' in sys.modules
type(self).is_pypy = w_is_pypy

self.runappdirect = True
def test_folding_of_binops_on_constants():
    def disassemble(func):
        from io import StringIO
        import sys, dis
        f = StringIO()
        tmp = sys.stdout
        sys.stdout = f
        dis.dis(func)
        sys.stdout = tmp
        result = f.getvalue()
        f.close()
        return result

    def dis_single(line):
        return disassemble(compile(line, '', 'single'))

    for line, elem in (
        ('a = 2+3+4', '(9)'),                   # chained fold
        ('"@"*4', "('@@@@')"),                  # check string ops
        ('a="abc" + "def"', "('abcdef')"),      # check string ops
        ('a = 3**4', '(81)'),                   # binary power
        ('a = 3*4', '(12)'),                    # binary multiply
        ('a = 13//4', '(3)'),                   # binary floor divide
        ('a = 14%4', '(2)'),                    # binary modulo
        ('a = 2+3', '(5)'),                     # binary add
        ('a = 13-4', '(9)'),                    # binary subtract
        ('a = (12,13)[1]', '(13)'),             # binary subscr
        ('a = 13 << 2', '(52)'),                # binary lshift
        ('a = 13 >> 2', '(3)'),                 # binary rshift
        ('a = 13 & 7', '(5)'),                  # binary and
        ('a = 13 ^ 7', '(10)'),                 # binary xor
        ('a = 13 | 7', '(15)'),                 # binary or
        ):
        asm = dis_single(line)
        print(asm)
        assert elem in asm, 'ELEMENT not in asm'
        assert 'BINARY_' not in asm, 'BINARY_in_asm'

    # Verify that unfoldables are skipped
    asm = dis_single('a=2+"b"')
    assert '(2)' in asm
    assert "('b')" in asm

    # Verify that large sequences do not result from folding
    asm = dis_single('a="x"*1000')
    assert '(1000)' in asm
try:
    test_folding_of_binops_on_constants()
finally:
    print("===aefwuiheawiu===")
from /tmp/pytest/usession-py3.12-1450/src.py

---------- Captured stderr call ----------
Traceback (most recent call last):
  File "/tmp/pytest/usession-py3.12-1450/src.py", line 109, in <module>
    test_folding_of_binops_on_constants()
  File "/tmp/pytest/usession-py3.12-1450/src.py", line 95, in test_folding_of_binops_on_constants
    asm = dis_single(line)
          ^^^^^^^^^^^^^^^^
  File "/tmp/pytest/usession-py3.12-1450/src.py", line 76, in dis_single
    return disassemble(compile(line, '', 'single'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pytest/usession-py3.12-1450/src.py", line 69, in disassemble
    dis.dis(func)
        ^^^
  File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 114, in dis
    _disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
  File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 555, in _disassemble_recursive
    disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive)
  File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 548, in disassemble
    _disassemble_bytes(_get_code_array(co, adaptive),
  File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 586, in _disassemble_bytes
    for instr in _get_instructions_bytes(code, varname_from_oparg, names,
  File "/build_dir/pypy-c-jit-linux-x86-64/build/lib-python/3/dis.py", line 483, in _get_instructions_bytes
    elif deop == LOAD_SUPER_ATTR:
                 ^^^^^^^^^^^^^^^
NameError: name 'LOAD_SUPER_ATTR' is not defined
builder: pypy-c-jit-linux-x86-64 build #11848+
test: pypy/interpreter/test/test_compiler.py::AppTestOptimizer::()::test_folding_of_binops_on_constants