python testrunner/app_level_tests.py in dir /build_dir/pypy-c-jit-linux-x86-64/build (timeout 4000 secs) watching logfiles {'pytestLog': 'pytest-A.log'} argv: ['python', 'testrunner/app_level_tests.py'] 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/build 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 TMPDIR=/tmp/pytest USER=buildslave USE_CURL=1 _=/python27_virt/bin/buildslave using PTY: False using config pypy/pytest-A.cfg using config pypy/pytest-A.py ignoring non-existant config /home/buildslave/machine-A_cfg.py -- interpreter/astcompiler/test -- interpreter/pyparser/test -- interpreter/test -- objspace/test -- objspace/std/test -- module/__builtin__/test -- module/__pypy__/test -- module/_abc/test -- module/_ast/test -- module/_cffi_backend/test -- module/_codecs/test -- module/_collections/test -- module/_continuation/test -- module/_cppyy/test -- module/_csv/test -- module/_demo/test -- module/_hpy_universal/test/_vendored -- module/_hpy_universal/test/pypy -- module/_io/test -- module/_jitlog/test -- module/_locale/test -- module/_lsprof/test -- module/_md5/test -- module/_minimal_curses/test -- module/_multibytecodec/test -- module/_multiprocessing/test -- module/_opcode/test -- module/_pickle/test -- module/_pickle_support/test -- module/_posixsubprocess/test -- module/_pypyjson/test -- module/_random/test -- module/_rawffi/alt/test -- module/_rawffi/test -- module/_socket/test -- module/_sre/test -- module/_vmprof/test -- module/_warnings/test -- module/_weakref/test -- module/_winreg/test -- module/array/test -- module/atexit/test -- module/binascii/test -- module/bz2/test -- module/cmath/test -- module/cpyext/test -- module/crypt/test -- module/errno/test -- module/exceptions/test -- module/faulthandler/test -- module/fcntl/test -- module/gc/test -- module/imp/test -- module/itertools/test -- module/marshal/test -- module/math/test -- module/micronumpy/test -- module/mmap/test -- module/operator/test -- module/posix/test -- module/pwd/test -- module/pyexpat/test -- module/pypyjit/test -- module/select/test -- module/signal/test -- module/struct/test -- module/sys/test -- module/termios/test -- module/test_lib_pypy -- module/thread/test -- module/time/test -- module/token/test -- module/unicodedata/test -- module/zipimport/test -- module/zlib/test -- total: 75 to run ++ 14:37:28 starting interpreter/astcompiler/test [1 started in total] __ interpreter/astcompiler/test [1 done in total, somefailed=False] ___________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 15 items interpreter/astcompiler/test/test_compiler.py ..s............ ===================== 14 passed, 1 skipped in 1.25 seconds ===================== ++ 14:37:33 starting interpreter/pyparser/test [2 started in total] __ interpreter/pyparser/test [2 done in total, somefailed=False] ______________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.24 seconds ========================= ++ 14:37:34 starting interpreter/test [3 started in total] __ interpreter/test [3 done in total, somefailed=True] ________________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 233 items interpreter/test/test_app_main.py sss interpreter/test/test_appinterp.py . interpreter/test/test_argument.py ............... interpreter/test/test_code.py ........... interpreter/test/test_compiler.py ................F......s..................F..F..F........F interpreter/test/test_exceptcomp.py ......... interpreter/test/test_executioncontext.py .... interpreter/test/test_extmodules.py s interpreter/test/test_gateway.py ....... interpreter/test/test_interpreter.py .............. interpreter/test/test_mixedmodule.py ssss interpreter/test/test_module.py ....FF.F............ interpreter/test/test_pyframe.py ..... interpreter/test/test_special.py ... interpreter/test/test_syntax.py ............................FFF...... interpreter/test/test_typedef.py ........... interpreter/test/test_zzpickle_and_slow.py .............................. =================================== FAILURES =================================== ____________________ AppTestCompiler.test_cpython_issue2301 ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7f451e5d6150>, 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_cpython_issue2301'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_cpython_issue2301'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_cpython_issue2301'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_cpython_issue2301'>} 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_cpython_issue2301'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_cpython_issue2301'>} 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_cpython_issue2301'>, '__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 0x7f451ec00500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._issue2301'>, '__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 0x7f451ec00dc0> 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 0x7f451ec00dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._issue2301'>, '__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_cpython_issue2301'>, '__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 0x7f451ec004b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._issue2301'>, '__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 0x7f451ec00460> 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 0x7f451ec00460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._issue2301'>, '__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_cpython_issue2301'>, '__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_cpython_issue2301'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_cpython_issue2301'> 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_cpython_issue2301 at 0x7f451f3231d0>, usemodules = None definitions = {'host_is_pypy': False, 'is_pypy': <bound method AppTestCompiler.w_is_pypy of <pypy.interpreter.test.test_compiler.AppTestCompiler object at 0x7f451ebdb250>>, 'runappdirect': True} defs = ['self.host_is_pypy = False\n', "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 0x7f451ebdb050> 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 AssertionError 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() self.host_is_pypy = False 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_cpython_issue2301(): try: compile(b"# coding: utf7\nprint '+XnQ-'", "dummy", "exec") except SyntaxError as v: assert v.text == "print '\u5e74'\n" else: assert False, "Expected SyntaxError" try: test_cpython_issue2301() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError _____________ AppTestOptimizer.test_folding_of_binops_on_constants _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: NameError: name 'LOAD_SUPER_ATTR' is not defined > func = <function <lambda> at 0x7f451e4c6150>, 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 0x7f45230c2f50> 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 0x7f451e57c7d0> 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 0x7f451e5e1230> 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 0x7f451e5e1230> 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 0x7f451e5e1500> 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 0x7f451e5e1460> 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 0x7f451e5e1460> 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 0x7f451f325050> usemodules = None definitions = {'is_pypy': <bound method AppTestOptimizer.w_is_pypy of <pypy.interpreter.test.test_compiler.AppTestOptimizer object at 0x7f451e4c3e50>>, '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 0x7f451e4c3910> 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 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-172/src.py ----------------------------- Captured stderr call ----------------------------- NameError: name 'LOAD_SUPER_ATTR' is not defined ___________________ AppTestOptimizer.test_optimize_list_comp ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: NameError: name 'BINARY_OP' is not defined > func = <function <lambda> at 0x7f451e4c6b50>, 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_optimize_list_comp'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_optimize_list_comp'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_optimize_list_comp'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_optimize_list_comp'>} 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_optimize_list_comp'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_optimize_list_comp'>} 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_optimize_list_comp'>, '__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 0x7f451f3025a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_comp'>, '__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 0x7f451ebd3960> 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 0x7f451ebd3960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_comp'>, '__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_optimize_list_comp'>, '__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 0x7f451ebd3460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_comp'>, '__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 0x7f451ebffaf0> 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 0x7f451ebffaf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_comp'>, '__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_optimize_list_comp'>, '__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_optimize_list_comp'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_optimize_list_comp'> 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_optimize_list_comp at 0x7f451f3251d0> usemodules = None definitions = {'is_pypy': <bound method AppTestOptimizer.w_is_pypy of <pypy.interpreter.test.test_compiler.AppTestOptimizer object at 0x7f451e43d310>>, '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 0x7f451e43d3d0> 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 NameError: name 'BINARY_OP' 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_optimize_list_comp(): source = """def _f(a): return [x for x in a if None] """ ns = {} exec(source, ns) code = ns['_f'].__code__ import sys, dis from io import StringIO s = StringIO() out = sys.stdout sys.stdout = s try: dis.dis(code) finally: sys.stdout = out output = s.getvalue() assert "LOAD_GLOBAL" not in output try: test_optimize_list_comp() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- NameError: name 'BINARY_OP' is not defined ___________________ AppTestOptimizer.test_call_method_kwargs ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: NameError: name 'LOAD_SUPER_ATTR' is not defined > func = <function <lambda> at 0x7f451e4437d0>, 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_call_method_kwargs'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_method_kwargs'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_method_kwargs'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_method_kwargs'>} 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_call_method_kwargs'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_method_kwargs'>} 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_call_method_kwargs'>, '__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 0x7f451e588c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hod_kwargs'>, '__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 0x7f451e588370> 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 0x7f451e588370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hod_kwargs'>, '__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_call_method_kwargs'>, '__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 0x7f451e588e10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hod_kwargs'>, '__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 0x7f451e588cd0> 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 0x7f451e588cd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hod_kwargs'>, '__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_call_method_kwargs'>, '__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_call_method_kwargs'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_method_kwargs'> 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_call_method_kwargs at 0x7f451f325350> usemodules = None definitions = {'is_pypy': <bound method AppTestOptimizer.w_is_pypy of <pypy.interpreter.test.test_compiler.AppTestOptimizer object at 0x7f451e5a7cd0>>, '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 0x7f451e5a7a90> 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 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_call_method_kwargs(): if not self.is_pypy(): skip("CALL_METHOD exists only on pypy") source = """def _f(a): return a.f(a=a) """ ns = {} exec(source, ns) code = ns['_f'].__code__ import sys, dis from io import StringIO s = StringIO() out = sys.stdout sys.stdout = s try: dis.dis(code) finally: sys.stdout = out output = s.getvalue() assert "CALL_METHOD" in output, output try: test_call_method_kwargs() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- NameError: name 'LOAD_SUPER_ATTR' is not defined ____________ AppTestExceptions.test_asterror_has_line_without_file _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7f451e5c4750>, 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_asterror_has_line_without_file'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asterror_has_line_without_file'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_asterror_has_line_without_file'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asterror_has_line_without_file'>} 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_asterror_has_line_without_file'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asterror_has_line_without_file'>} 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_asterror_has_line_without_file'>, '__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 0x7f451f2f9b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...thout_file'>, '__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 0x7f451f2f9870> 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 0x7f451f2f9870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...thout_file'>, '__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_asterror_has_line_without_file'>, '__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 0x7f451f2f9b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...thout_file'>, '__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 0x7f451e40e550> 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 0x7f451e40e550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...thout_file'>, '__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_asterror_has_line_without_file'>, '__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_asterror_has_line_without_file'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_asterror_has_line_without_file'> 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_asterror_has_line_without_file at 0x7f451f3257d0> usemodules = None, definitions = {}, defs = [] 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 AssertionError 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 test_asterror_has_line_without_file(): code = u"print(1)\na/2 = 5\n" with raises(SyntaxError) as excinfo: compile(code, 'not a file!', 'exec') assert excinfo.value.text == "a/2 = 5\n" try: test_asterror_has_line_without_file() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError ______ AppTest_ModuleObject.test_repr_with_loader_with_valid_module_repr _______ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7f451e70c750>, 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_repr_with_loader_with_valid_mod..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_valid_module_repr'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_repr_with_loader_with_valid_mod..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_valid_module_repr'>} 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_repr_with_loader_with_valid_mod..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_valid_module_repr'>} 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_repr_with_loader_with_valid_module_repr'>, '__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 0x7f451e710730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_repr'>, '__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 0x7f451e710870> 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 0x7f451e710870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_repr'>, '__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_repr_with_loader_with_valid_module_repr'>, '__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 0x7f451e710910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_repr'>, '__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 0x7f451e710690> 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 0x7f451e710690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_repr'>, '__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_repr_with_loader_with_valid_module_repr'>, '__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_repr_with_loader_with_valid_module_repr'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_repr_with_loader_with_valid_module_repr'> 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_repr_with_loader_with_valid_module_repr at 0x7f451eb52250> usemodules = None, definitions = {}, defs = [] 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 AssertionError 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 test_repr_with_loader_with_valid_module_repr(): import sys test_module = type(sys)("test_module", "doc") # If the module has a __loader__ and that loader has a module_repr() # method, call it with a single argument, which is the module object. # The value returned is used as the module's repr. class CustomLoader: @classmethod def module_repr(cls, module): mod_repr = ("<module {mod_name}: " "{cls} Test>".format(mod_name=repr(module.__name__), cls=repr(cls.__name__))) return mod_repr test_module.__loader__ = CustomLoader assert repr(test_module) == "<module 'test_module': 'CustomLoader' Test>" try: test_repr_with_loader_with_valid_module_repr() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError ____ AppTest_ModuleObject.test_repr_with_loader_with_module_repr_wrong_type ____ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError: DID NOT RAISE > func = <function <lambda> at 0x7f451e70cb50>, 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_repr_with_loader_with_module_re...iCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_module_repr_wrong_type'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_repr_with_loader_with_module_re...iCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_module_repr_wrong_type'>} 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_repr_with_loader_with_module_re...iCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_module_repr_wrong_type'>} 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_repr_with_loader_with_module_repr_wrong_type'>, '__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 0x7f451e3b2960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...wrong_type'>, '__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 0x7f451e3b2aa0> 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 0x7f451e3b2aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...wrong_type'>, '__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_repr_with_loader_with_module_repr_wrong_type'>, '__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 0x7f451e3b26e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...wrong_type'>, '__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 0x7f451e3b2a00> 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 0x7f451e3b2a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...wrong_type'>, '__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_repr_with_loader_with_module_repr_wrong_type'>, '__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_repr_with_loader_with_module_repr_wrong_type'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_repr_with_loader_with_module_repr_wrong_type'> 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_repr_with_loader_with_module_repr_wrong_type at 0x7f451eb522d0> usemodules = None, definitions = {}, defs = [] 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 AssertionError: DID NOT RAISE 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 test_repr_with_loader_with_module_repr_wrong_type(): import sys test_module = type(sys)("test_module", "doc") # This return value must be a string. class BuggyCustomLoader: @classmethod def module_repr(cls, module): return 5 test_module.__loader__ = BuggyCustomLoader raises(TypeError, repr, test_module) try: test_repr_with_loader_with_module_repr_wrong_type() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError: DID NOT RAISE _____ AppTest_ModuleObject.test_repr_with_loader_with_raising_module_repr2 _____ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError: DID NOT RAISE > func = <function <lambda> at 0x7f451e70c650>, 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_repr_with_loader_with_raising_m...ltiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_raising_module_repr2'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_repr_with_loader_with_raising_m...ltiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_raising_module_repr2'>} 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_repr_with_loader_with_raising_m...ltiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_with_loader_with_raising_module_repr2'>} 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_repr_with_loader_with_raising_module_repr2'>, '__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 0x7f451e465af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dule_repr2'>, '__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 0x7f451e465320> 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 0x7f451e465320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dule_repr2'>, '__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_repr_with_loader_with_raising_module_repr2'>, '__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 0x7f451e465460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dule_repr2'>, '__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 0x7f451e465370> 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 0x7f451e465370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dule_repr2'>, '__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_repr_with_loader_with_raising_module_repr2'>, '__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_repr_with_loader_with_raising_module_repr2'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_repr_with_loader_with_raising_module_repr2'> 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_repr_with_loader_with_raising_module_repr2 at 0x7f451eb523d0> usemodules = None, definitions = {}, defs = [] 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 AssertionError: DID NOT RAISE 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 test_repr_with_loader_with_raising_module_repr2(): import sys test_module = type(sys)("test_module", "doc") # If an exception occurs in module_repr(), the exception is caught # and discarded, and the calculation of the module's repr continues # as if module_repr() did not exist. class CustomLoaderWithRaisingRepr: @classmethod def module_repr(cls, module): raise KeyboardInterrupt test_module.__loader__ = CustomLoaderWithRaisingRepr raises(KeyboardInterrupt, 'repr(test_module)') try: test_repr_with_loader_with_raising_module_repr2() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError: DID NOT RAISE _______________ AppTestSyntaxError.test_tokenizer_error_location _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7f451e58b650>, 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_tokenizer_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tokenizer_error_location'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_tokenizer_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tokenizer_error_location'>} 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_tokenizer_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tokenizer_error_location'>} 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_tokenizer_error_location'>, '__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 0x7f451e6256e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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 0x7f451e625960> 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 0x7f451e625960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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_tokenizer_error_location'>, '__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 0x7f451ebf93c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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 0x7f451ebf9a00> 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 0x7f451ebf9a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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_tokenizer_error_location'>, '__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_tokenizer_error_location'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_tokenizer_error_location'> 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_tokenizer_error_location at 0x7f451e805ad0> usemodules = None, definitions = {}, defs = [] 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 AssertionError 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 test_tokenizer_error_location(): line4 = "if ?: pass\n" try: exec("print\nprint\nprint\n" + line4) except SyntaxError as e: assert e.lineno == 4 assert e.text == line4 assert e.offset == e.text.index('?') + 1 else: raise Exception("no SyntaxError??") try: test_tokenizer_error_location() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError ________________ AppTestSyntaxError.test_grammar_error_location ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7f451e6ee4d0>, 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_grammar_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_grammar_error_location'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_grammar_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_grammar_error_location'>} 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_grammar_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_grammar_error_location'>} 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_grammar_error_location'>, '__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 0x7f451e5bda00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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 0x7f451e5bdcd0> 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 0x7f451e5bdcd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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_grammar_error_location'>, '__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 0x7f451e84ccd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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 0x7f451e84c7d0> 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 0x7f451e84c7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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_grammar_error_location'>, '__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_grammar_error_location'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_grammar_error_location'> 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_grammar_error_location at 0x7f451e805b50> usemodules = None, definitions = {}, defs = [] 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 AssertionError 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 test_grammar_error_location(): try: exec("""if 1: class Foo: bla a as e bar """) except SyntaxError as e: assert e.lineno == 4 assert e.text.endswith('a as e\n') print(e.offset, e.text.index('as')) assert e.offset == e.text.index('as') + 1 # offset is 1-based else: raise Exception("no SyntaxError??") try: test_grammar_error_location() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError ______________ AppTestSyntaxError.test_astbuilder_error_location _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7f451e6ee050>, 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_astbuilder_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_astbuilder_error_location'>} 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 0x7f45230c2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_astbuilder_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_astbuilder_error_location'>} 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_astbuilder_error_location'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_astbuilder_error_location'>} 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_astbuilder_error_location'>, '__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 0x7f451e358cd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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 0x7f451e358e10> 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 0x7f451e358e10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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_astbuilder_error_location'>, '__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 0x7f451e358a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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 0x7f451e358d70> 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 0x7f451e358d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...r_location'>, '__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_astbuilder_error_location'>, '__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_astbuilder_error_location'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_astbuilder_error_location'> 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_astbuilder_error_location at 0x7f451e805bd0> usemodules = None, definitions = {}, defs = [] 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 AssertionError 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 test_astbuilder_error_location(): program = "(1, 2) += (3, 4)\n" try: exec(program) except SyntaxError as e: assert e.lineno == 1 assert e.text == program else: raise Exception("no SyntaxError??") try: test_astbuilder_error_location() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-172/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError =========================== short test summary info ============================ FAIL interpreter/test/test_compiler.py::AppTestCompiler::()::test_cpython_issue2301 FAIL interpreter/test/test_compiler.py::AppTestOptimizer::()::test_folding_of_binops_on_constants FAIL interpreter/test/test_compiler.py::AppTestOptimizer::()::test_optimize_list_comp FAIL interpreter/test/test_compiler.py::AppTestOptimizer::()::test_call_method_kwargs FAIL interpreter/test/test_compiler.py::AppTestExceptions::()::test_asterror_has_line_without_file FAIL interpreter/test/test_module.py::AppTest_ModuleObject::()::test_repr_with_loader_with_valid_module_repr FAIL interpreter/test/test_module.py::AppTest_ModuleObject::()::test_repr_with_loader_with_module_repr_wrong_type FAIL interpreter/test/test_module.py::AppTest_ModuleObject::()::test_repr_with_loader_with_raising_module_repr2 FAIL interpreter/test/test_syntax.py::AppTestSyntaxError::()::test_tokenizer_error_location FAIL interpreter/test/test_syntax.py::AppTestSyntaxError::()::test_grammar_error_location FAIL interpreter/test/test_syntax.py::AppTestSyntaxError::()::test_astbuilder_error_location =============== 11 failed, 213 passed, 9 skipped in 9.72 seconds =============== ++ 14:37:46 starting objspace/test [4 started in total] __ objspace/test [4 done in total, somefailed=False] __________________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:37:48 starting objspace/std/test [5 started in total] __ objspace/std/test [5 done in total, somefailed=False] ______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 1568 items objspace/std/test/test_bytearrayobject.py ..................................................................................... objspace/std/test/test_bytesobject.py .............................................................................................. objspace/std/test/test_celldict.py ......sss objspace/std/test/test_dictmultiobject.py ...........................................................................................................................................ssssssss objspace/std/test/test_dictproxy.py ................ objspace/std/test/test_floatobject.py ................................................. objspace/std/test/test_identitydict.py sssss objspace/std/test/test_identityset.py sssssss objspace/std/test/test_index.py ................................... objspace/std/test/test_intobject.py .......................................................................................................................... objspace/std/test/test_jsondict.py .......... objspace/std/test/test_kwargsdict.py sssssss objspace/std/test/test_listobject.py ................................................................................... objspace/std/test/test_longobject.py ...................................s........... objspace/std/test/test_mapdict.py ..................ssssssssssssssssssssssssssssssssssssssssssssssss objspace/std/test/test_memoryobject.py .......................................... objspace/std/test/test_methodcache.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss objspace/std/test/test_newformat.py ............................................................... objspace/std/test/test_obj.py ...................................... objspace/std/test/test_prebuiltint.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss objspace/std/test/test_proxy.py ssssssssssss objspace/std/test/test_proxy_function.py ........ objspace/std/test/test_proxy_internals.py s...... objspace/std/test/test_proxy_iter.py . objspace/std/test/test_proxy_object.py .......... objspace/std/test/test_proxy_usercreated.py s objspace/std/test/test_setobject.py .......................................................................................... objspace/std/test/test_sliceobject.py ........ objspace/std/test/test_smalllongobject.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss objspace/std/test/test_specialisedtupleobject.py ........................................... objspace/std/test/test_tupleobject.py ........................ objspace/std/test/test_typeobject.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.....sssssssssssss objspace/std/test/test_unicodeobject.py .... objspace/std/test/test_userobject.py . ================== 1046 passed, 522 skipped in 36.40 seconds =================== ++ 14:38:26 starting module/__builtin__/test [6 started in total] __ module/__builtin__/test [6 done in total, somefailed=False] ________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 282 items module/__builtin__/test/test_abstractinst.py ........... module/__builtin__/test/test_breakpoint.py ........ module/__builtin__/test/test_builtin.py ....................................................................... module/__builtin__/test/test_construct_singletons.py . module/__builtin__/test/test_descriptor.py ................................... module/__builtin__/test/test_dir.py ........... module/__builtin__/test/test_filter.py ........ module/__builtin__/test/test_filter_pickle.py ..... module/__builtin__/test/test_format.py . module/__builtin__/test/test_functional.py ....................................................................................... module/__builtin__/test/test_map_pickle.py ... module/__builtin__/test/test_minmax.py ....................... module/__builtin__/test/test_rawinput.py .. module/__builtin__/test/test_sum.py . module/__builtin__/test/test_vars.py ... module/__builtin__/test/test_zip.py ........... module/__builtin__/test/test_zip_pickle.py . ========================== 282 passed in 8.40 seconds ========================== ++ 14:38:36 starting module/__pypy__/test [7 started in total] __ module/__pypy__/test [7 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 75 items module/__pypy__/test/test_builders.py ..... module/__pypy__/test/test_bytebuffer.py ... module/__pypy__/test/test_debug.py sssssss module/__pypy__/test/test_identitydict.py ...... module/__pypy__/test/test_intop.py ........... module/__pypy__/test/test_locals2fast.py ..... module/__pypy__/test/test_magic.py .......s.. module/__pypy__/test/test_newmemoryview.py ........ module/__pypy__/test/test_os.py . module/__pypy__/test/test_signal.py ..... module/__pypy__/test/test_special.py sssssssssss..s ==================== 55 passed, 20 skipped in 7.75 seconds ===================== ++ 14:38:47 starting module/_abc/test [8 started in total] __ module/_abc/test [8 done in total, somefailed=False] _______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 3 items module/_abc/test/test_abc.py ... =========================== 3 passed in 0.10 seconds =========================== ++ 14:38:48 starting module/_ast/test [9 started in total] __ module/_ast/test [9 done in total, somefailed=True] ________________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 52 items module/_ast/test/test_ast.py .........................F.....................F.... =================================== FAILURES =================================== _________________________ AppTestAST.test_functiondef __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: TypeError: required field 'type_params' missing from FunctionDef > func = <function <lambda> at 0x7f2b53a49d50>, 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_functiondef'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_functiondef'>} 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 0x7f2b56967f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_functiondef'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_functiondef'>} 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_functiondef'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_functiondef'>} 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_functiondef'>, '__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 0x7f2b53a1c690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unctiondef'>, '__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 0x7f2b53a1c5f0> 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 0x7f2b53a1c5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unctiondef'>, '__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_functiondef'>, '__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 0x7f2b53a1c280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unctiondef'>, '__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 0x7f2b53a1c820> 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 0x7f2b53a1c820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unctiondef'>, '__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_functiondef'>, '__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_functiondef'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_functiondef'> 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_functiondef at 0x7f2b53a89c50> usemodules = ['_struct', 'binascii'] definitions = {'ast': <module '_ast' (built-in)>, 'get_ast': <bound method AppTestAST.w_get_ast of <pypy.module._ast.test.test_ast.AppTestAST instance at 0x7f2b53a1c7d0>>} defs = ['import _ast; self.ast = _ast\n', 'def w_get_ast(self, source, mode="exec", flags=0, feature_version=-1):\n ast = ...ure_version=feature_version)\n assert isinstance(mod, ast.mod)\n return mod', 'type(self).get_ast = w_get_ast\n'] symbol = 'get_ast' value = <bound method AppTestAST.w_get_ast of <pypy.module._ast.test.test_ast.AppTestAST instance at 0x7f2b53a1c7d0>> code = <py._code.code.Code object at 0x7f2b53a26050> 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 TypeError: required field 'type_params' missing from FunctionDef 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') missing = set(['_struct', 'binascii']).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 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() import _ast; self.ast = _ast def w_get_ast(self, source, mode="exec", flags=0, feature_version=-1): ast = self.ast mod = compile(source, "<test>", mode, ast.PyCF_ONLY_AST | flags, _feature_version=feature_version) assert isinstance(mod, ast.mod) return mod type(self).get_ast = w_get_ast def test_functiondef(): import ast as ast_utils import _ast as ast fAst = ast.FunctionDef( name="foo", args=ast.arguments( args=[], vararg=None, kwarg=None, defaults=[], kwonlyargs=[], kw_defaults=[], posonlyargs=[]), body=[ast.Expr(ast.Constant('docstring', None))], decorator_list=[], lineno=5, col_offset=0) exprAst = ast.Interactive(body=[fAst]) ast_utils.fix_missing_locations(exprAst) compiled = compile(exprAst, "<foo>", "single") # d = {} eval(compiled, d, d) assert type(d['foo']) is type(lambda: 42) assert d['foo']() is None try: test_functiondef() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-178/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- TypeError: required field 'type_params' missing from FunctionDef ___________ AppTestAST.test_fstring_self_documenting_feature_version ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError: DID NOT RAISE > func = <function <lambda> at 0x7f2b539929d0>, 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_fstring_self_documenting_featur...MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fstring_self_documenting_feature_version'>} 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 0x7f2b56967f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fstring_self_documenting_featur...MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fstring_self_documenting_feature_version'>} 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_fstring_self_documenting_featur...MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fstring_self_documenting_feature_version'>} 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_fstring_self_documenting_feature_version'>, '__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 0x7f2b537ce1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_version'>, '__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 0x7f2b537cea00> 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 0x7f2b537cea00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_version'>, '__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_fstring_self_documenting_feature_version'>, '__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 0x7f2b537cee60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_version'>, '__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 0x7f2b537ce4b0> 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 0x7f2b537ce4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_version'>, '__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_fstring_self_documenting_feature_version'>, '__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_fstring_self_documenting_feature_version'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fstring_self_documenting_feature_version'> 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_fstring_self_documenting_feature_version at 0x7f2b53a857d0> usemodules = ['_struct', 'binascii'] definitions = {'ast': <module '_ast' (built-in)>, 'get_ast': <bound method AppTestAST.w_get_ast of <pypy.module._ast.test.test_ast.AppTestAST instance at 0x7f2b537ce9b0>>} defs = ['import _ast; self.ast = _ast\n', 'def w_get_ast(self, source, mode="exec", flags=0, feature_version=-1):\n ast = ...ure_version=feature_version)\n assert isinstance(mod, ast.mod)\n return mod', 'type(self).get_ast = w_get_ast\n'] symbol = 'get_ast' value = <bound method AppTestAST.w_get_ast of <pypy.module._ast.test.test_ast.AppTestAST instance at 0x7f2b537ce9b0>> code = <py._code.code.Code object at 0x7f2b538b0d10> 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 AssertionError: DID NOT RAISE 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') missing = set(['_struct', 'binascii']).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 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() import _ast; self.ast = _ast def w_get_ast(self, source, mode="exec", flags=0, feature_version=-1): ast = self.ast mod = compile(source, "<test>", mode, ast.PyCF_ONLY_AST | flags, _feature_version=feature_version) assert isinstance(mod, ast.mod) return mod type(self).get_ast = w_get_ast def test_fstring_self_documenting_feature_version(): raises(SyntaxError, self.get_ast, "f'{x=}'", feature_version=7) self.get_ast("'f{x=}'", feature_version=7) try: test_fstring_self_documenting_feature_version() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-178/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError: DID NOT RAISE =========================== short test summary info ============================ FAIL module/_ast/test/test_ast.py::AppTestAST::()::test_functiondef FAIL module/_ast/test/test_ast.py::AppTestAST::()::test_fstring_self_documenting_feature_version ===================== 2 failed, 50 passed in 2.05 seconds ====================== ++ 14:38:52 starting module/_cffi_backend/test [10 started in total] __ module/_cffi_backend/test [10 done in total, somefailed=False] _____________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 443 items module/_cffi_backend/test/test_c.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss module/_cffi_backend/test/test_fastpath.py .................. module/_cffi_backend/test/test_ffi_obj.py ............................................. module/_cffi_backend/test/test_re_python.py .................... module/_cffi_backend/test/test_recompiler.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss module/_cffi_backend/test/test_unicode_literals.py ....... ==================== 90 passed, 353 skipped in 4.04 seconds ==================== ++ 14:38:57 starting module/_codecs/test [11 started in total] __ module/_codecs/test [11 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 89 items module/_codecs/test/test_codecs.py ....................sss.................................................................. ===================== 86 passed, 3 skipped in 2.99 seconds ===================== ++ 14:39:02 starting module/_collections/test [12 started in total] __ module/_collections/test [12 done in total, somefailed=False] ______________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:03 starting module/_continuation/test [13 started in total] __ module/_continuation/test [13 done in total, somefailed=False] _____________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 72 items / 2 skipped module/_continuation/test/test_generator.py .... module/_continuation/test/test_greenlet.py ............................ module/_continuation/test/test_stacklet.py ........................................ ===================== 72 passed, 2 skipped in 2.90 seconds ===================== ++ 14:39:08 starting module/_cppyy/test [14 started in total] __ module/_cppyy/test [14 done in total, somefailed=False] ____________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:09 starting module/_csv/test [15 started in total] __ module/_csv/test [15 done in total, somefailed=False] ______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 27 items module/_csv/test/test_dialect.py .............. module/_csv/test/test_reader.py ............. ========================== 27 passed in 0.82 seconds =========================== ++ 14:39:12 starting module/_demo/test [16 started in total] __ module/_demo/test [16 done in total, somefailed=False] _____________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 1 items module/_demo/test/test_sieve.py s ========================== 1 skipped in 0.04 seconds =========================== ++ 14:39:14 starting module/_hpy_universal/test/_vendored [17 started in total] __ module/_hpy_universal/test/_vendored [17 done in total, somefailed=False] __ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:15 starting module/_hpy_universal/test/pypy [18 started in total] __ module/_hpy_universal/test/pypy [18 done in total, somefailed=False] _______ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:17 starting module/_io/test [19 started in total] __ module/_io/test [19 done in total, somefailed=False] _______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 134 items / 1 skipped module/_io/test/test_bufferedio.py .................................................s..................................................... module/_io/test/test_fileio.py ............................... ==================== 133 passed, 2 skipped in 5.86 seconds ===================== ++ 14:39:26 starting module/_jitlog/test [20 started in total] __ module/_jitlog/test [20 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 1 items module/_jitlog/test/test__jitlog.py . =========================== 1 passed in 0.05 seconds =========================== ++ 14:39:27 starting module/_locale/test [21 started in total] __ module/_locale/test [21 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 15 items module/_locale/test/test_locale.py ssssssssssssss. ===================== 1 passed, 14 skipped in 0.05 seconds ===================== ++ 14:39:29 starting module/_lsprof/test [22 started in total] __ module/_lsprof/test [22 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 6 items module/_lsprof/test/test_cprofile.py ...... =========================== 6 passed in 1.19 seconds =========================== ++ 14:39:32 starting module/_md5/test [23 started in total] __ module/_md5/test [23 done in total, somefailed=False] ______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 8 items module/_md5/test/test_md5.py ........ =========================== 8 passed in 0.24 seconds =========================== ++ 14:39:33 starting module/_minimal_curses/test [24 started in total] __ module/_minimal_curses/test [24 done in total, somefailed=False] ___________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:35 starting module/_multibytecodec/test [25 started in total] __ module/_multibytecodec/test [25 done in total, somefailed=False] ___________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 3 items module/_multibytecodec/test/test_multibtye_codecs.py ... =========================== 3 passed in 0.14 seconds =========================== ++ 14:39:37 starting module/_multiprocessing/test [26 started in total] __ module/_multiprocessing/test [26 done in total, somefailed=False] __________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 10 items module/_multiprocessing/test/test_semaphore.py ......... module/_multiprocessing/test/test_win32.py s ===================== 9 passed, 1 skipped in 0.63 seconds ====================== ++ 14:39:39 starting module/_opcode/test [27 started in total] __ module/_opcode/test [27 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:41 starting module/_pickle/test [28 started in total] __ module/_pickle/test [28 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:43 starting module/_pickle_support/test [29 started in total] __ module/_pickle_support/test [29 done in total, somefailed=False] ___________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:39:45 starting module/_posixsubprocess/test [30 started in total] __ module/_posixsubprocess/test [30 done in total, somefailed=False] __________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.20 seconds ========================= ++ 14:39:46 starting module/_pypyjson/test [31 started in total] __ module/_pypyjson/test [31 done in total, somefailed=False] _________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 29 items module/_pypyjson/test/test__pypyjson.py ............................. ========================== 29 passed in 1.08 seconds =========================== ++ 14:39:49 starting module/_random/test [32 started in total] __ module/_random/test [32 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 12 items module/_random/test/test_random.py ............ ========================== 12 passed in 0.49 seconds =========================== ++ 14:39:51 starting module/_rawffi/alt/test [33 started in total] __ module/_rawffi/alt/test [33 done in total, somefailed=False] _______________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 61 items module/_rawffi/alt/test/test_ffitype.py ..... module/_rawffi/alt/test/test_funcptr.py ....ss.................................... module/_rawffi/alt/test/test_struct.py .............. ===================== 59 passed, 2 skipped in 2.42 seconds ===================== ++ 14:39:55 starting module/_rawffi/test [34 started in total] __ module/_rawffi/test [34 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 79 items module/_rawffi/test/test__rawffi.py ..................................................................... module/_rawffi/test/test_exit.py . module/_rawffi/test/test_nested.py ...... module/_rawffi/test/test_tracker.py sss ===================== 76 passed, 3 skipped in 2.70 seconds ===================== ++ 14:39:59 starting module/_socket/test [35 started in total] __ module/_socket/test [35 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.79 seconds ========================= ++ 14:40:02 starting module/_sre/test [36 started in total] __ module/_sre/test [36 done in total, somefailed=False] ______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 94 items module/_sre/test/test_app_sre.py ..............................ssssssssssssssssssssssssssssssssssss module/_sre/test/test_sre_buf.py ............................ ==================== 58 passed, 36 skipped in 2.87 seconds ===================== ++ 14:40:06 starting module/_vmprof/test [37 started in total] __ module/_vmprof/test [37 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 5 items module/_vmprof/test/test__vmprof.py ..... =========================== 5 passed in 0.43 seconds =========================== ++ 14:40:08 starting module/_warnings/test [38 started in total] __ module/_warnings/test [38 done in total, somefailed=False] _________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:40:10 starting module/_weakref/test [39 started in total] __ module/_weakref/test [39 done in total, somefailed=False] __________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:40:11 starting module/_winreg/test [40 started in total] __ module/_winreg/test [40 done in total, somefailed=False] ___________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items / 1 skipped ========================== 1 skipped in 0.01 seconds =========================== ++ 14:40:13 starting module/array/test [41 started in total] __ module/array/test [41 done in total, somefailed=False] _____________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 60 items module/array/test/test_array.py ............................................................ ========================== 60 passed in 1.88 seconds =========================== ++ 14:40:17 starting module/atexit/test [42 started in total] __ module/atexit/test [42 done in total, somefailed=False] ____________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 14:40:18 starting module/binascii/test [43 started in total] __ module/binascii/test [43 done in total, somefailed=False] __________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 18 items module/binascii/test/test_binascii.py .................. ========================== 18 passed in 0.62 seconds =========================== ++ 14:40:21 starting module/bz2/test [44 started in total] __ module/bz2/test [44 done in total, somefailed=False] _______________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 45 items module/bz2/test/test_bz2_compdecomp.py ssssssssssssssss module/bz2/test/test_bz2_file.py ssssssssssssssssssssssssssss module/bz2/test/test_large.py s ========================== 45 skipped in 1.51 seconds ========================== ++ 14:40:24 starting module/cmath/test [45 started in total] __ module/cmath/test [45 done in total, somefailed=False] _____________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 16 items module/cmath/test/test_cmath.py ................ ========================== 16 passed in 0.48 seconds =========================== ++ 14:40:26 starting module/cpyext/test [46 started in total] __ module/cpyext/test [46 done in total, somefailed=True] _____________________ ============================= test session starts ============================== platform linux2 -- Python 2.7.18, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 hypothesis profile 'default' -> deadline=None, database=DirectoryBasedExampleDatabase('/build_dir/pypy-c-jit-linux-x86-64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-x86-64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-x86-64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 446 items / 1 skipped module/cpyext/test/test_arraymodule.py FFFFFFFFFFxFFFFFFF module/cpyext/test/test_async_iter.py sss module/cpyext/test/test_boolobject.py FFF module/cpyext/test/test_borrow.py FFF module/cpyext/test/test_buffer.py FFFFF module/cpyext/test/test_bytearrayobject.py FFFFFF module/cpyext/test/test_bytesobject.py FFFFFFFFF module/cpyext/test/test_capsule.py FFF module/cpyext/test/test_cell.py F module/cpyext/test/test_classobject.py FF module/cpyext/test/test_codecs.py F module/cpyext/test/test_complexobject.py FFFFF module/cpyext/test/test_contextvars.py F module/cpyext/test/test_cpyext.py s.FFFFFFFFFFFFF.FsFFsFFFF module/cpyext/test/test_datetime.py FFFFFFF module/cpyext/test/test_dictobject.py FFFFFFFFFFF module/cpyext/test/test_eval.py FFFFFFFFF module/cpyext/test/test_exception.py FF module/cpyext/test/test_fileobject.py F module/cpyext/test/test_floatobject.py FFFFFFFFFFFF module/cpyext/test/test_frameobject.py FFFF module/cpyext/test/test_funcobject.py FFFFFFF module/cpyext/test/test_genobject.py FF module/cpyext/test/test_getargs.py FFFFFFFFFFFFFFFF module/cpyext/test/test_import.py FF module/cpyext/test/test_iterator.py FF module/cpyext/test/test_listobject.py FFFFF module/cpyext/test/test_longobject.py FFFFFFFFFFFFFFF module/cpyext/test/test_marshal.py FF module/cpyext/test/test_memoryobject.py FsFFFFFFFFF module/cpyext/test/test_methodobject.py FFFFFFFFFFFFFF module/cpyext/test/test_misc.py F module/cpyext/test/test_module.py FFFFFFFFFFFFFFFFFFFFFFF module/cpyext/test/test_namespaceobject.py F module/cpyext/test/test_number.py FFF module/cpyext/test/test_object.py FFFFFFFFF.FFFFFFFFF module/cpyext/test/test_pyerrors.py FFFFFFFFFFFFFsFFFFFFFFF module/cpyext/test/test_pymem.py F module/cpyext/test/test_pysignals.py F module/cpyext/test/test_pystate.py FFFFxFFFFFFF module/cpyext/test/test_pystrhex.py F module/cpyext/test/test_pystrtod.py F module/cpyext/test/test_sequence.py FFFF module/cpyext/test/test_setobject.py F module/cpyext/test/test_sliceobject.py FFFFFF module/cpyext/test/test_structseq.py F module/cpyext/test/test_sysmodule.py FFF module/cpyext/test/test_thread.py sssssF module/cpyext/test/test_tupleobject.py FFFFF module/cpyext/test/test_typeobject.py FFFFFFFFFFFFFF.FFFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.FFFFFFFFFFFFFF module/cpyext/test/test_unicodeobject.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF module/cpyext/test/test_userslots.py FFFF module/cpyext/test/test_version.py Fs module/cpyext/test/test_weakref.py FF =================================== FAILURES =================================== ________________________ AppTestArrayModule.test_basic _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee883350>, 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_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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_basic'>, '__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 0x7ff8ee93cf00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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 0x7ff8ee93c050> 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 0x7ff8ee93c050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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_basic'>, '__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 0x7ff8ee93c190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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 0x7ff8ee91c500> 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 0x7ff8ee91c500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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_basic'>, '__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_basic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_basic'> 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_basic at 0x7ff8ef4219d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee885710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8f447a850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_basic(): module = self.import_module(name='array') import sys arr = module.array('i', [1,2,3]) assert arr.typecode == 'i' assert arr.itemsize == 4 assert arr[2] == 3 assert len(arr.buffer_info()) == 2 exc = raises(TypeError, module.array.append) errstr = str(exc.value) if sys.implementation.name == 'pypy': assert errstr.startswith("descriptor 'append' of 'array' object"), errstr else: assert errstr.startswith("unbound method array.append"), errstr arr.append(4) assert arr.tolist() == [1, 2, 3, 4] assert len(arr) == 4 try: test_basic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestArrayModule.test_iter _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee93bbd0>, 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_iter'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iter'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_iter'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iter'>} 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_iter'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iter'>} 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_iter'>, '__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 0x7ff8ee8305f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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 0x7ff8ee830690> 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 0x7ff8ee830690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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_iter'>, '__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 0x7ff8ee830780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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 0x7ff8ee8306e0> 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 0x7ff8ee8306e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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_iter'>, '__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_iter'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_iter'> 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_iter at 0x7ff8ef421a50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8eebb1110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eebb1210> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_iter(): module = self.import_module(name='array') arr = module.array('i', [1,2,3]) sum = 0 for i in arr: sum += i assert sum == 6 try: test_iter() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestArrayModule.test_index _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee883450>, 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_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_index'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_index'>} 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_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_index'>} 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_index'>, '__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 0x7ff8eeaaa730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_index'>, '__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 0x7ff8eecff050> 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 0x7ff8eecff050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_index'>, '__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_index'>, '__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 0x7ff8ee803730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_index'>, '__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 0x7ff8ee803820> 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 0x7ff8ee803820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_index'>, '__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_index'>, '__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_index'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_index'> 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_index at 0x7ff8ef421ad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8eee8b0d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eea1a590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_index(): module = self.import_module(name='array') arr = module.array('i', [1, 2, 3, 4]) assert arr[3] == 4 raises(IndexError, arr.__getitem__, 10) del arr[2] assert arr.tolist() == [1, 2, 4] arr[2] = 99 assert arr.tolist() == [1, 2, 99] try: test_index() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestArrayModule.test_slice_get _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eebc0a50>, 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_slice_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slice_get'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_slice_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slice_get'>} 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_slice_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slice_get'>} 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_slice_get'>, '__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 0x7ff8ef1243c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._slice_get'>, '__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 0x7ff8ef124280> 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 0x7ff8ef124280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._slice_get'>, '__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_slice_get'>, '__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 0x7ff8ee830af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._slice_get'>, '__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 0x7ff8ee830410> 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 0x7ff8ee830410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._slice_get'>, '__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_slice_get'>, '__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_slice_get'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_slice_get'> 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_slice_get at 0x7ff8ef421b50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee885a10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee8858d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_slice_get(): module = self.import_module(name='array') arr = module.array('i', [1, 2, 3, 4]) assert arr[:].tolist() == [1, 2, 3, 4] assert arr[1:].tolist() == [2, 3, 4] assert arr[:2].tolist() == [1, 2] assert arr[1:3].tolist() == [2, 3] try: test_slice_get() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestArrayModule.test_slice_object _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eebc0ed0>, 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_slice_object'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slice_object'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_slice_object'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slice_object'>} 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_slice_object'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slice_object'>} 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_slice_object'>, '__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 0x7ff8eeb626e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ice_object'>, '__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 0x7ff8eeb62780> 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 0x7ff8eeb62780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ice_object'>, '__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_slice_object'>, '__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 0x7ff8eeb62870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ice_object'>, '__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 0x7ff8eeb627d0> 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 0x7ff8eeb627d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ice_object'>, '__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_slice_object'>, '__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_slice_object'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_slice_object'> 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_slice_object at 0x7ff8ef421bd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8eebb1210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee815b50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_slice_object(): module = self.import_module(name='array') arr = module.array('i', [1, 2, 3, 4]) assert arr[slice(1, 3)].tolist() == [2,3] arr[slice(1, 3)] = module.array('i', [21, 22, 23]) assert arr.tolist() == [1, 21, 22, 23, 4] del arr[slice(1, 3)] assert arr.tolist() == [1, 23, 4] raises(TypeError, 'arr[slice(1, 3)] = "abc"') try: test_slice_object() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestArrayModule.test_buffer ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee8833d0>, 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_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer'>} 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_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer'>} 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_buffer'>, '__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 0x7ff8eef13af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_buffer'>, '__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 0x7ff8eef13e60> 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 0x7ff8eef13e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_buffer'>, '__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_buffer'>, '__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 0x7ff8ee97dc80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_buffer'>, '__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 0x7ff8ee97dcd0> 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 0x7ff8ee97dcd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_buffer'>, '__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_buffer'>, '__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_buffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_buffer'> 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_buffer at 0x7ff8ef421c50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee815710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee885990> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_buffer(): import sys module = self.import_module(name='array') arr = module.array('i', [1, 2, 3, 4]) buf = memoryview(arr) buf[1] = 2 if sys.byteorder == 'big': expected = b'\0\0\0\x01\0\0\0\x02\0\0\0\x03\0\0\0\x04' else: expected = b'\x01\0\0\0\x02\0\0\0\x03\0\0\0\x04\0\0\0' assert bytes(buf) == expected # make sure memory_attach is called buf2 = module.passthrough(buf) assert str(buf2) == str(buf) try: test_buffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestArrayModule.test_releasebuffer _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee828050>, 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_releasebuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_releasebuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer'>} 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_releasebuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer'>} 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_releasebuffer'>, '__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 0x7ff8ee7fc8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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 0x7ff8ee7fc9b0> 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 0x7ff8ee7fc9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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_releasebuffer'>, '__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 0x7ff8ee7fca50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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 0x7ff8ee7fcb40> 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 0x7ff8ee7fcb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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_releasebuffer'>, '__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_releasebuffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_releasebuffer'> 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_releasebuffer at 0x7ff8ef421cd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8eeb9c050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eeb9cf50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_releasebuffer(): module = self.import_module(name='array') arr = module.array('i', [1,2,3,4]) initial = module.get_releasebuffer_cnt() module.create_and_release_buffer(arr) assert module.get_releasebuffer_cnt() == initial + 1 try: test_releasebuffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestArrayModule.test_Py_buffer _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eebc0f50>, 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_Py_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_buffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Py_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_buffer'>} 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_Py_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_buffer'>} 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_Py_buffer'>, '__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 0x7ff8ee78f500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._Py_buffer'>, '__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 0x7ff8ee78f460> 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 0x7ff8ee78f460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._Py_buffer'>, '__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_Py_buffer'>, '__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 0x7ff8ee78f5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._Py_buffer'>, '__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 0x7ff8ee78f640> 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 0x7ff8ee78f640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._Py_buffer'>, '__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_Py_buffer'>, '__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_Py_buffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Py_buffer'> 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_Py_buffer at 0x7ff8ef421d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8eebb1190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9aebd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Py_buffer(): module = self.import_module(name='array') arr = module.array('i', [1,2,3,4]) initial = module.get_releasebuffer_cnt() m = memoryview(arr) assert module.get_releasebuffer_cnt() == initial del m self.debug_collect() assert module.get_releasebuffer_cnt() == initial + 1 try: test_Py_buffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestArrayModule.test_0d_view ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee883450>, 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_0d_view'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_0d_view'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_0d_view'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_0d_view'>} 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_0d_view'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_0d_view'>} 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_0d_view'>, '__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 0x7ff8eeb58a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_0d_view'>, '__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 0x7ff8eeb58af0> 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 0x7ff8eeb58af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_0d_view'>, '__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_0d_view'>, '__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 0x7ff8eeb58b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_0d_view'>, '__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 0x7ff8eeb58c80> 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 0x7ff8eeb58c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_0d_view'>, '__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_0d_view'>, '__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_0d_view'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_0d_view'> 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_0d_view at 0x7ff8ef421dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8eeac4550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eeb9c090> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_0d_view(): module = self.import_module(name='array') arr = module.array('B', b'\0\0\0\x01') buf = memoryview(arr).cast('i', shape=()) assert bytes(buf) == b'\0\0\0\x01' assert buf.shape == () assert buf.strides == () try: test_0d_view() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestArrayModule.test_binop_mul_impl ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eea10f50>, 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_binop_mul_impl'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_binop_mul_impl'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_binop_mul_impl'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_binop_mul_impl'>} 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_binop_mul_impl'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_binop_mul_impl'>} 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_binop_mul_impl'>, '__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 0x7ff8ee827550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...p_mul_impl'>, '__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 0x7ff8ee8275f0> 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 0x7ff8ee8275f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...p_mul_impl'>, '__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_binop_mul_impl'>, '__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 0x7ff8ee8276e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...p_mul_impl'>, '__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 0x7ff8ee827640> 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 0x7ff8ee827640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...p_mul_impl'>, '__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_binop_mul_impl'>, '__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_binop_mul_impl'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_binop_mul_impl'> 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_binop_mul_impl at 0x7ff8ef421e50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee9ac710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9ac310> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_binop_mul_impl(): # check that rmul is called module = self.import_module(name='array') arr = module.array('i', [2]) res = [1, 2, 3] * arr assert res == [1, 2, 3, 1, 2, 3] try: test_binop_mul_impl() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestArrayModule.test_string_buf ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eea31050>, 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_string_buf'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_string_buf'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_string_buf'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_string_buf'>} 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_string_buf'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_string_buf'>} 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_string_buf'>, '__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 0x7ff8eeaf75a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...string_buf'>, '__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 0x7ff8eeaf7820> 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 0x7ff8eeaf7820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...string_buf'>, '__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_string_buf'>, '__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 0x7ff8eeaf7910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...string_buf'>, '__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 0x7ff8eeaf79b0> 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 0x7ff8eeaf79b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...string_buf'>, '__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_string_buf'>, '__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_string_buf'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_string_buf'> 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_string_buf at 0x7ff8ef421f50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee9ac210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9acad0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_string_buf(): module = self.import_module(name='array') import sys arr = module.array('u', '123') view = memoryview(arr) print("view.shape", view.shape) print("view.strides", view.strides) isize = view.itemsize if sys.platform == 'win32': assert isize == 2 else: assert isize == 4 assert module.write_buffer_len(arr) == isize * 3 assert len(module.readbuffer_as_string(arr)) == isize * 3 assert len(module.readbuffer_as_string(view)) == isize * 3 try: test_string_buf() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestArrayModule.test_subclass _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee828bd0>, 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_subclass'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclass'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_subclass'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclass'>} 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_subclass'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclass'>} 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_subclass'>, '__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 0x7ff8ee750410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_subclass'>, '__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 0x7ff8ee750500> 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 0x7ff8ee750500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_subclass'>, '__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_subclass'>, '__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 0x7ff8ee750460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_subclass'>, '__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 0x7ff8ee7505a0> 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 0x7ff8ee7505a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_subclass'>, '__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_subclass'>, '__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_subclass'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_subclass'> 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_subclass at 0x7ff8ef422050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee78c490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee78c410> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_subclass(): import struct module = self.import_module(name='array') class Sub(module.array): pass arr = Sub('i', [2]) res = [1, 2, 3] * arr assert res == [1, 2, 3, 1, 2, 3] val = module.readbuffer_as_string(arr) assert val == struct.pack('i', 2) try: test_subclass() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestArrayModule.test_unicode_readbuffer __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eea31050>, 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_unicode_readbuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unicode_readbuffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_unicode_readbuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unicode_readbuffer'>} 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_unicode_readbuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unicode_readbuffer'>} 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_unicode_readbuffer'>, '__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 0x7ff8ee7ee370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...readbuffer'>, '__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 0x7ff8ee7ee140> 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 0x7ff8ee7ee140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...readbuffer'>, '__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_unicode_readbuffer'>, '__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 0x7ff8ee7ee910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...readbuffer'>, '__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 0x7ff8ee7ee6e0> 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 0x7ff8ee7ee6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...readbuffer'>, '__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_unicode_readbuffer'>, '__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_unicode_readbuffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_unicode_readbuffer'> 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_unicode_readbuffer at 0x7ff8ef4220d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee974790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9748d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_unicode_readbuffer(): # Not really part of array, refactor import struct module = self.import_module(name='array') val = module.readbuffer_as_string(b'abcd') assert val == b'abcd' try: test_unicode_readbuffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestArrayModule.test_readinto _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eea10f50>, 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_readinto'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_readinto'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_readinto'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_readinto'>} 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_readinto'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_readinto'>} 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_readinto'>, '__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 0x7ff8ee766500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_readinto'>, '__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 0x7ff8ee7665f0> 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 0x7ff8ee7665f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_readinto'>, '__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_readinto'>, '__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 0x7ff8ee766690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_readinto'>, '__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 0x7ff8ee766780> 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 0x7ff8ee766780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_readinto'>, '__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_readinto'>, '__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_readinto'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_readinto'> 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_readinto at 0x7ff8ef422150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee974290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98bc50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_readinto(): module = self.import_module(name='array') a = module.array('B') a.fromstring(b'0123456789') filename = self.udir + "/_test_file" f = open(filename, 'w+b') f.write(b'foobar') f.seek(0) n = f.readinto(a) f.close() assert n == 6 assert len(a) == 10 assert a.tostring() == b'foobar6789' try: test_readinto() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestArrayModule.test_iowrite ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee9770d0>, 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_iowrite'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iowrite'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_iowrite'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iowrite'>} 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_iowrite'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iowrite'>} 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_iowrite'>, '__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 0x7ff8ee95f460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_iowrite'>, '__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 0x7ff8ee95f870> 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 0x7ff8ee95f870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_iowrite'>, '__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_iowrite'>, '__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 0x7ff8ee95f500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_iowrite'>, '__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 0x7ff8ee95f370> 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 0x7ff8ee95f370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_iowrite'>, '__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_iowrite'>, '__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_iowrite'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_iowrite'> 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_iowrite at 0x7ff8ef4221d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee98b310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98b850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_iowrite(): module = self.import_module(name='array') from io import BytesIO a = module.array('B') a.fromstring(b'0123456789') fd = BytesIO() # only test that it works fd.write(a) try: test_iowrite() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________ AppTestArrayModule.test_getitem_via_PySequence_GetItem ____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeb97050>, 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_getitem_via_PySequence_GetItem'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_via_PySequence_GetItem'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getitem_via_PySequence_GetItem'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_via_PySequence_GetItem'>} 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_getitem_via_PySequence_GetItem'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_via_PySequence_GetItem'>} 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_getitem_via_PySequence_GetItem'>, '__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 0x7ff8eeb735f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ce_GetItem'>, '__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 0x7ff8eeb73870> 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 0x7ff8eeb73870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ce_GetItem'>, '__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_getitem_via_PySequence_GetItem'>, '__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 0x7ff8eeb73960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ce_GetItem'>, '__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 0x7ff8eeb73a00> 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 0x7ff8eeb73a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ce_GetItem'>, '__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_getitem_via_PySequence_GetItem'>, '__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_getitem_via_PySequence_GetItem'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getitem_via_PySequence_GetItem'> 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_getitem_via_PySequence_GetItem at 0x7ff8ef422250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee9a7790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9a7350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getitem_via_PySequence_GetItem(): module = self.import_module(name='array') a = module.array('i', range(10)) # call via tp_as_mapping.mp_subscript assert 5 == a[-5] # PySequence_ITEM used to call space.getitem() which # prefers tp_as_mapping.mp_subscript over tp_as_sequence.sq_item # Now fixed so this test raises (array_item does not add len(a), # array_subscr does) raises(IndexError, module.getitem, a, -5) try: test_getitem_via_PySequence_GetItem() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestArrayModule.test_subclass_with_attribute ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee9770d0>, 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_subclass_with_attribute'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclass_with_attribute'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_subclass_with_attribute'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclass_with_attribute'>} 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_subclass_with_attribute'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclass_with_attribute'>} 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_subclass_with_attribute'>, '__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 0x7ff8eeaf5b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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 0x7ff8eeaf5c80> 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 0x7ff8eeaf5c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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_subclass_with_attribute'>, '__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 0x7ff8eeaf5820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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 0x7ff8eeaf50f0> 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 0x7ff8eeaf50f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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_subclass_with_attribute'>, '__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_subclass_with_attribute'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_subclass_with_attribute'> 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_subclass_with_attribute at 0x7ff8ef4222d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestArrayModule.w_compile_module of <pypy.module.cpyext.test.test_arraymodule.AppT...ule.w_import_extension of <pypy.module.cpyext.test.test_arraymodule.AppTestArrayModule object at 0x7ff8ee7dd590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee7ddd50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_subclass_with_attribute(): module = self.import_module(name='array') class Sub(module.array): def addattrib(self): print('called addattrib') self.attrib = True import gc module.subclass_with_attribute(Sub, "addattrib", "attrib", gc.collect) assert Sub.__module__ == __name__ try: test_subclass_with_attribute() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestBoolMacros.test_macros _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee8833d0>, 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_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macros'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macros'>} 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_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macros'>} 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_macros'>, '__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 0x7ff8ee9b0be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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 0x7ff8ee9b06e0> 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 0x7ff8ee9b06e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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_macros'>, '__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 0x7ff8ee9b0960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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 0x7ff8ee9b0730> 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 0x7ff8ee9b0730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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_macros'>, '__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_macros'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_macros'> 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_macros at 0x7ff8ef3954d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBoolMacros.w_compile_module of <pypy.module.cpyext.test.test_boolobject.AppTes...acros.w_import_extension of <pypy.module.cpyext.test.test_boolobject.AppTestBoolMacros object at 0x7ff8ee974310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eeb71ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_macros(): module = self.import_extension('foo', [ ("get_true", "METH_NOARGS", "Py_RETURN_TRUE;"), ("get_false", "METH_NOARGS", "Py_RETURN_FALSE;"), ]) assert module.get_true() == True assert module.get_false() == False try: test_macros() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestBoolMacros.test_toint _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eea3b5d0>, 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_toint'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_toint'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_toint'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_toint'>} 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_toint'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_toint'>} 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_toint'>, '__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 0x7ff8ee83da00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_toint'>, '__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 0x7ff8ee83d870> 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 0x7ff8ee83d870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_toint'>, '__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_toint'>, '__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 0x7ff8ee83d8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_toint'>, '__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 0x7ff8ee83df50> 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 0x7ff8ee83df50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_toint'>, '__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_toint'>, '__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_toint'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_toint'> 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_toint at 0x7ff8ef395550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBoolMacros.w_compile_module of <pypy.module.cpyext.test.test_boolobject.AppTes...acros.w_import_extension of <pypy.module.cpyext.test.test_boolobject.AppTestBoolMacros object at 0x7ff8ee9dea90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee78ca90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_toint(): module = self.import_extension('foo', [ ("to_int", "METH_O", ''' if (args->ob_type->tp_as_number && args->ob_type->tp_as_number->nb_int) { return args->ob_type->tp_as_number->nb_int(args); } else { PyErr_SetString(PyExc_TypeError,"cannot convert bool to int"); return NULL; } '''), ]) assert module.to_int(False) == 0 assert module.to_int(True) == 1 try: test_toint() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestBoolMacros.test_check _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee8833d0>, 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_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check'>} 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_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check'>} 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_check'>, '__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 0x7ff8ee819870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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 0x7ff8ee819460> 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 0x7ff8ee819460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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_check'>, '__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 0x7ff8ee819820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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 0x7ff8ee819c80> 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 0x7ff8ee819c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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_check'>, '__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_check'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_check'> 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_check at 0x7ff8ef3955d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBoolMacros.w_compile_module of <pypy.module.cpyext.test.test_boolobject.AppTes...acros.w_import_extension of <pypy.module.cpyext.test.test_boolobject.AppTestBoolMacros object at 0x7ff8ee9a7410>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9a7350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_check(): module = self.import_extension('foo', [ ("type_check", "METH_O", ''' return PyLong_FromLong(PyBool_Check(args)); ''')]) assert module.type_check(True) assert module.type_check(False) assert not module.type_check(None) assert not module.type_check(1.0) try: test_check() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestBorrow.test_tuple_borrowing ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee883750>, 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_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tuple_borrowing'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tuple_borrowing'>} 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_tuple_borrowing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tuple_borrowing'>} 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_tuple_borrowing'>, '__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 0x7ff8ee83ddc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._borrowing'>, '__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 0x7ff8ee83dd70> 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 0x7ff8ee83dd70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._borrowing'>, '__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_tuple_borrowing'>, '__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 0x7ff8ee83deb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._borrowing'>, '__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 0x7ff8ee83d190> 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 0x7ff8ee83d190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._borrowing'>, '__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_tuple_borrowing'>, '__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_tuple_borrowing'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_tuple_borrowing'> 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_tuple_borrowing at 0x7ff8ef395ad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBorrow.w_compile_module of <pypy.module.cpyext.test.test_borrow.AppTestBorrow ...AppTestBorrow.w_import_extension of <pypy.module.cpyext.test.test_borrow.AppTestBorrow object at 0x7ff8ee744f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee744d50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_tuple_borrowing(): module = self.import_extension('foo', [ ("test_borrowing", "METH_NOARGS", """ PyObject *t = PyTuple_New(1); if (t == NULL) { return NULL; } PyObject *f = PyFloat_FromDouble(42.0); PyObject *g = NULL; printf("Refcnt1: %ld\\n", f->ob_refcnt); PyTuple_SetItem(t, 0, f); // steals reference printf("Refcnt2: %ld\\n", f->ob_refcnt); f = PyTuple_GetItem(t, 0); // borrows reference printf("Refcnt3: %ld\\n", f->ob_refcnt); g = PyTuple_GetItem(t, 0); // borrows reference again printf("Refcnt4: %ld\\n", f->ob_refcnt); printf("COMPARE: %i\\n", f == g); fflush(stdout); Py_DECREF(t); Py_RETURN_TRUE; """), ]) assert module.test_borrowing() # the test should not leak try: test_tuple_borrowing() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestBorrow.test_borrow_destroy _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee810250>, 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_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_borrow_destroy'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_borrow_destroy'>} 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_borrow_destroy'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_borrow_destroy'>} 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_borrow_destroy'>, '__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 0x7ff8ee6d0780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_destroy'>, '__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 0x7ff8ee6d0870> 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 0x7ff8ee6d0870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_destroy'>, '__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_borrow_destroy'>, '__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 0x7ff8ee6d0910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_destroy'>, '__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 0x7ff8ee6d0a00> 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 0x7ff8ee6d0a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_destroy'>, '__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_borrow_destroy'>, '__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_borrow_destroy'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_borrow_destroy'> 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_borrow_destroy at 0x7ff8ef395b50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBorrow.w_compile_module of <pypy.module.cpyext.test.test_borrow.AppTestBorrow ...AppTestBorrow.w_import_extension of <pypy.module.cpyext.test.test_borrow.AppTestBorrow object at 0x7ff8eeb716d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eeb711d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_borrow_destroy(): module = self.import_extension('foo', [ ("test_borrow_destroy", "METH_NOARGS", """ PyObject *i = PyLong_FromLong(42); PyObject *j; PyObject *t1 = PyTuple_Pack(1, i); if (t1 == NULL) { return NULL; } PyObject *t2 = PyTuple_Pack(1, i); if (t2 == NULL) { return NULL; } Py_DECREF(i); i = PyTuple_GetItem(t1, 0); PyTuple_GetItem(t2, 0); Py_DECREF(t2); j = PyLong_FromLong(PyLong_AsLong(i)); Py_DECREF(t1); return j; """), ]) assert module.test_borrow_destroy() == 42 try: test_borrow_destroy() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestBorrow.test_double_borrow _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee822850>, 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_double_borrow'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_double_borrow'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_double_borrow'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_double_borrow'>} 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_double_borrow'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_double_borrow'>} 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_double_borrow'>, '__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 0x7ff8ee7b7550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ble_borrow'>, '__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 0x7ff8ee7b7af0> 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 0x7ff8ee7b7af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ble_borrow'>, '__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_double_borrow'>, '__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 0x7ff8ee7b7a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ble_borrow'>, '__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 0x7ff8ee7b7be0> 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 0x7ff8ee7b7be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ble_borrow'>, '__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_double_borrow'>, '__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_double_borrow'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_double_borrow'> 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_double_borrow at 0x7ff8ef395bd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBorrow.w_compile_module of <pypy.module.cpyext.test.test_borrow.AppTestBorrow ...AppTestBorrow.w_import_extension of <pypy.module.cpyext.test.test_borrow.AppTestBorrow object at 0x7ff8ee744590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee744ad0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_double_borrow(): module = self.import_extension('foo', [ ("run", "METH_NOARGS", """ PyObject *t = PyTuple_New(1); PyObject *s = PyRun_String("set()", Py_eval_input, Py_None, Py_None); PyObject *w = PyWeakref_NewRef(s, Py_None); PyTuple_SetItem(t, 0, s); PyTuple_GetItem(t, 0); PyTuple_GetItem(t, 0); Py_DECREF(t); return w; """), ]) wr = module.run() # check that the set() object was deallocated self.debug_collect() assert wr() is None try: test_double_borrow() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestBuffer.test_AsWriteBuffer _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee814950>, 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_AsWriteBuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsWriteBuffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_AsWriteBuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsWriteBuffer'>} 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_AsWriteBuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsWriteBuffer'>} 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_AsWriteBuffer'>, '__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 0x7ff8ee6d0460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...riteBuffer'>, '__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 0x7ff8ee6d0f00> 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 0x7ff8ee6d0f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...riteBuffer'>, '__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_AsWriteBuffer'>, '__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 0x7ff8ee6d0730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...riteBuffer'>, '__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 0x7ff8ee6d00f0> 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 0x7ff8ee6d00f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...riteBuffer'>, '__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_AsWriteBuffer'>, '__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_AsWriteBuffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_AsWriteBuffer'> 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_AsWriteBuffer at 0x7ff8ef3bc550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBuffer.w_compile_module of <pypy.module.cpyext.test.test_buffer.AppTestBuffer ...AppTestBuffer.w_import_extension of <pypy.module.cpyext.test.test_buffer.AppTestBuffer object at 0x7ff8eeb71190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee73fe50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_AsWriteBuffer(): import array module = self.import_extension('buffer', [ ('write_buffer_len', 'METH_O', """ void* buf; Py_ssize_t buf_len; if (PyObject_AsWriteBuffer(args, &buf, &buf_len) < 0) { //PyErr_SetString(PyExc_ValueError, "bad value"); return NULL; } return PyLong_FromLong(buf_len); """)]) assert module.write_buffer_len(bytearray(b'123')) == 3 assert module.write_buffer_len(array.array('i', [1, 2, 3])) == 12 # import _cffi_backend BChar = _cffi_backend.new_primitive_type("char") BCharPtr = _cffi_backend.new_pointer_type(BChar) BCharArray = _cffi_backend.new_array_type(BCharPtr, None) p = _cffi_backend.newp(BCharArray, b"abcde") bb = _cffi_backend.buffer(p) assert module.write_buffer_len(bb) == 6 try: test_AsWriteBuffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestBuffer.test_mmap_buffer ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7f70d0>, 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_mmap_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_mmap_buffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_mmap_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_mmap_buffer'>} 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_mmap_buffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_mmap_buffer'>} 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_mmap_buffer'>, '__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 0x7ff8ee741410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...map_buffer'>, '__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 0x7ff8ee741500> 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 0x7ff8ee741500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...map_buffer'>, '__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_mmap_buffer'>, '__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 0x7ff8ee7415a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...map_buffer'>, '__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 0x7ff8ee741690> 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 0x7ff8ee741690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...map_buffer'>, '__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_mmap_buffer'>, '__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_mmap_buffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_mmap_buffer'> 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_mmap_buffer at 0x7ff8ef3bc5d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBuffer.w_compile_module of <pypy.module.cpyext.test.test_buffer.AppTestBuffer ...AppTestBuffer.w_import_extension of <pypy.module.cpyext.test.test_buffer.AppTestBuffer object at 0x7ff8ee70dbd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee70d890> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_mmap_buffer(): module = self.import_extension('mmap_buffer', [ ('isbuffer', 'METH_O', """ Py_buffer view; if (PyObject_GetBuffer(args, &view, PyBUF_ANY_CONTIGUOUS|PyBUF_WRITABLE) != 0) { return NULL; } return PyLong_FromLong(1); """)]) import os, mmap tmpname = os.path.join(self.udir, 'test_mmap_buffer') print(tmpname) with open(tmpname, 'w+b') as f: f.write(b'123') f.flush() m = mmap.mmap(f.fileno(), 3) assert module.isbuffer(m) == 1 try: test_mmap_buffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestBuffer.test_applevel __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eea27050>, 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_applevel'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_applevel'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_applevel'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_applevel'>} 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_applevel'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_applevel'>} 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_applevel'>, '__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 0x7ff8ee7c8820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_applevel'>, '__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 0x7ff8ee7c8f00> 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 0x7ff8ee7c8f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_applevel'>, '__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_applevel'>, '__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 0x7ff8ee7c8d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_applevel'>, '__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 0x7ff8ee9b0be0> 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 0x7ff8ee9b0be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_applevel'>, '__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_applevel'>, '__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_applevel'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_applevel'> 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_applevel at 0x7ff8ef3bc650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBuffer.w_compile_module of <pypy.module.cpyext.test.test_buffer.AppTestBuffer ...AppTestBuffer.w_import_extension of <pypy.module.cpyext.test.test_buffer.AppTestBuffer object at 0x7ff8ee70df10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee73f150> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_applevel(): module = self.import_extension("foo", [ ("getbuffer", "METH_O", """ Py_buffer view; if (!PyObject_CheckBuffer(args)) { PyErr_SetString(PyExc_TypeError, "no buffer interface"); return NULL; } if (PyObject_GetBuffer(args, &view, PyBUF_SIMPLE) != 0) { return NULL; } PyObject *ret = view.obj; Py_INCREF(ret); PyBuffer_Release(&view); return ret; """)]) class B(): def __buffer__(self, flags): return memoryview(b'hello') ret = module.getbuffer(B()) assert ret == b'hello' try: test_applevel() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestBuffer.test_argparse __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7f70d0>, 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_argparse'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_argparse'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_argparse'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_argparse'>} 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_argparse'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_argparse'>} 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_argparse'>, '__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 0x7ff8ee68f8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argparse'>, '__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 0x7ff8ee68f9b0> 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 0x7ff8ee68f9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argparse'>, '__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_argparse'>, '__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 0x7ff8ee68fa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argparse'>, '__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 0x7ff8ee68fb40> 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 0x7ff8ee68fb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argparse'>, '__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_argparse'>, '__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_argparse'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_argparse'> 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_argparse at 0x7ff8ef3bc6d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBuffer.w_compile_module of <pypy.module.cpyext.test.test_buffer.AppTestBuffer ...AppTestBuffer.w_import_extension of <pypy.module.cpyext.test.test_buffer.AppTestBuffer object at 0x7ff8ee70de90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee70d9d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_argparse(): # issue 5136 module = self.import_extension("foo", [ ("getbuffer", "METH_VARARGS", """ Py_buffer buf; if (!PyArg_ParseTuple(args, "y*", &buf)) return NULL; int ro = buf.readonly; PyBuffer_Release(&buf); return PyLong_FromLong(ro); """), ]) # buf = array.array("B", [0] * 1024) buf = bytearray(1024) # buf = (ctypes.c_uint8 * 1024)() ret = module.getbuffer(buf) for i in range(2000): assert ret == 0, "failed in iteration %d" % i try: test_argparse() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________ AppTestBuffer.test_bytearray_release_buffer_unlocks_resize __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7c38d0>, 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_bytearray_release_buffer_unlock..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_release_buffer_unlocks_resize'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytearray_release_buffer_unlock..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_release_buffer_unlocks_resize'>} 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_bytearray_release_buffer_unlock..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_release_buffer_unlocks_resize'>} 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_bytearray_release_buffer_unlocks_resize'>, '__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 0x7ff8ee982f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...cks_resize'>, '__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 0x7ff8ee982b90> 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 0x7ff8ee982b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...cks_resize'>, '__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_bytearray_release_buffer_unlocks_resize'>, '__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 0x7ff8ee982280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...cks_resize'>, '__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 0x7ff8ee982960> 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 0x7ff8ee982960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...cks_resize'>, '__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_bytearray_release_buffer_unlocks_resize'>, '__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_bytearray_release_buffer_unlocks_resize'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytearray_release_buffer_unlocks_resize'> 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_bytearray_release_buffer_unlocks_resize at 0x7ff8ef3bc750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBuffer.w_compile_module of <pypy.module.cpyext.test.test_buffer.AppTestBuffer ...AppTestBuffer.w_import_extension of <pypy.module.cpyext.test.test_buffer.AppTestBuffer object at 0x7ff8ee73d790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee73f5d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytearray_release_buffer_unlocks_resize(): # Acquire and immediately release: bytearray must be resizable after. # Also verify that holding the buffer blocks resize until release. module = self.import_extension("foo", [ ("acquire_and_release", "METH_O", """ Py_buffer buf; if (PyObject_GetBuffer(args, &buf, PyBUF_SIMPLE) < 0) return NULL; PyBuffer_Release(&buf); Py_RETURN_NONE; """), ("acquire", "METH_O", """ Py_buffer *buf = (Py_buffer *)malloc(sizeof(Py_buffer)); if (PyObject_GetBuffer(args, buf, PyBUF_SIMPLE) < 0) { free(buf); return NULL; } return PyLong_FromVoidPtr(buf); """), ("release", "METH_O", """ Py_buffer *buf = (Py_buffer *)PyLong_AsVoidPtr(args); PyBuffer_Release(buf); free(buf); Py_RETURN_NONE; """), ]) b = bytearray(b'hello') module.acquire_and_release(b) b.append(ord('x')) assert b == bytearray(b'hellox') b2 = bytearray(b'world') token = module.acquire(b2) raises(BufferError, b2.append, ord('!')) module.release(token) b2.append(ord('!')) assert b2 == bytearray(b'world!') try: test_bytearray_release_buffer_unlocks_resize() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestStringObject.test_basic ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7f70d0>, 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_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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_basic'>, '__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 0x7ff8ee72b2d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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 0x7ff8ee72b0a0> 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 0x7ff8ee72b0a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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_basic'>, '__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 0x7ff8ee72bbe0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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 0x7ff8ee982eb0> 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 0x7ff8ee982eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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_basic'>, '__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_basic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_basic'> 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_basic at 0x7ff8ef3c20d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringObject.w_compile_module of <pypy.module.cpyext.test.test_bytearrayobject..._import_extension of <pypy.module.cpyext.test.test_bytearrayobject.AppTestStringObject object at 0x7ff8ee73f290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee73da50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_basic(): module = self.import_extension('foo', [ ("get_hello1", "METH_NOARGS", """ return PyByteArray_FromStringAndSize( "Hello world<should not be included>", 11); """), ("get_hello2", "METH_NOARGS", """ return PyByteArray_FromStringAndSize("Hello world", 12); """), ("test_Size", "METH_NOARGS", """ PyObject* s = PyByteArray_FromStringAndSize("Hello world", 12); int result = 0; if(PyByteArray_Size(s) == 12) { result = 1; } Py_DECREF(s); return PyBool_FromLong(result); """), ("test_is_bytearray", "METH_VARARGS", """ return PyBool_FromLong(PyByteArray_Check(PyTuple_GetItem(args, 0))); """)], prologue='#include <stdlib.h>') assert module.get_hello1() == b'Hello world' assert module.get_hello2() == b'Hello world\x00' assert module.test_Size() assert module.test_is_bytearray(bytearray(b"")) assert not module.test_is_bytearray(()) try: test_basic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestStringObject.test_bytearray_buffer_init ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee810450>, 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_bytearray_buffer_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_buffer_init'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytearray_buffer_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_buffer_init'>} 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_bytearray_buffer_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_buffer_init'>} 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_bytearray_buffer_init'>, '__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 0x7ff8ee6dc6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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 0x7ff8ee6dc7d0> 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 0x7ff8ee6dc7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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_bytearray_buffer_init'>, '__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 0x7ff8ee6dc870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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 0x7ff8ee6dc960> 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 0x7ff8ee6dc960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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_bytearray_buffer_init'>, '__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_bytearray_buffer_init'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytearray_buffer_init'> 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_bytearray_buffer_init at 0x7ff8ef3c2150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringObject.w_compile_module of <pypy.module.cpyext.test.test_bytearrayobject..._import_extension of <pypy.module.cpyext.test.test_bytearrayobject.AppTestStringObject object at 0x7ff8ee7f4d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee7f4750> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytearray_buffer_init(): module = self.import_extension('foo', [ ("getbytearray", "METH_NOARGS", """ PyObject *s, *t; char* c; s = PyByteArray_FromStringAndSize(NULL, 4); if (s == NULL) return NULL; t = PyByteArray_FromStringAndSize(NULL, 3); if (t == NULL) return NULL; Py_DECREF(t); c = PyByteArray_AsString(s); if (c == NULL) { PyErr_SetString(PyExc_ValueError, "non-null bytearray object expected"); return NULL; } c[0] = 'a'; c[1] = 'b'; c[2] = 0; c[3] = 'c'; return s; """), ]) s = module.getbytearray() assert len(s) == 4 assert s == b'ab\x00c' try: test_bytearray_buffer_init() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestStringObject.test_bytearray_mutable __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7f70d0>, 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_bytearray_mutable'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_mutable'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytearray_mutable'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_mutable'>} 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_bytearray_mutable'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_mutable'>} 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_bytearray_mutable'>, '__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 0x7ff8ee741320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ay_mutable'>, '__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 0x7ff8ee72baf0> 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 0x7ff8ee72baf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ay_mutable'>, '__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_bytearray_mutable'>, '__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 0x7ff8ee72b050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ay_mutable'>, '__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 0x7ff8ee72b9b0> 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 0x7ff8ee72b9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ay_mutable'>, '__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_bytearray_mutable'>, '__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_bytearray_mutable'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytearray_mutable'> 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_bytearray_mutable at 0x7ff8ef3c21d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringObject.w_compile_module of <pypy.module.cpyext.test.test_bytearrayobject..._import_extension of <pypy.module.cpyext.test.test_bytearrayobject.AppTestStringObject object at 0x7ff8ee745210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee7454d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytearray_mutable(): module = self.import_extension('foo', [ ("mutable", "METH_NOARGS", """ PyObject *base; base = PyByteArray_FromStringAndSize("test", 10); if (PyByteArray_GET_SIZE(base) != 10) return PyLong_FromLong(-PyByteArray_GET_SIZE(base)); memcpy(PyByteArray_AS_STRING(base), "works", 6); Py_INCREF(base); return base; """), ]) s = module.mutable() if s == b'\x00' * 10: assert False, "no RW access to bytearray" assert s[:6] == b'works\x00' try: test_bytearray_mutable() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestStringObject.test_AsByteArray _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7c3850>, 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_AsByteArray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsByteArray'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_AsByteArray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsByteArray'>} 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_AsByteArray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsByteArray'>} 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_AsByteArray'>, '__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 0x7ff8ee6595a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sByteArray'>, '__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 0x7ff8ee659820> 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 0x7ff8ee659820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sByteArray'>, '__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_AsByteArray'>, '__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 0x7ff8ee659910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sByteArray'>, '__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 0x7ff8ee6599b0> 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 0x7ff8ee6599b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sByteArray'>, '__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_AsByteArray'>, '__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_AsByteArray'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_AsByteArray'> 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_AsByteArray at 0x7ff8ef3c2250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringObject.w_compile_module of <pypy.module.cpyext.test.test_bytearrayobject..._import_extension of <pypy.module.cpyext.test.test_bytearrayobject.AppTestStringObject object at 0x7ff8ee98a6d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98a410> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_AsByteArray(): module = self.import_extension('foo', [ ("getbytearray", "METH_NOARGS", """ const char *c; PyObject *s2, *s1 = PyByteArray_FromStringAndSize("test", 4); if (s1 == NULL) return NULL; c = PyByteArray_AsString(s1); s2 = PyByteArray_FromStringAndSize(c, 4); Py_DECREF(s1); return s2; """), ]) s = module.getbytearray() assert s == b'test' try: test_AsByteArray() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestStringObject.test_manipulations ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7f70d0>, 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_manipulations'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_manipulations'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_manipulations'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_manipulations'>} 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_manipulations'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_manipulations'>} 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_manipulations'>, '__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 0x7ff8ee96acd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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 0x7ff8ee72b9b0> 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 0x7ff8ee72b9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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_manipulations'>, '__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 0x7ff8ee72b500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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 0x7ff8ee72b0a0> 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 0x7ff8ee72b0a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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_manipulations'>, '__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_manipulations'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_manipulations'> 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_manipulations at 0x7ff8ef3c22d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringObject.w_compile_module of <pypy.module.cpyext.test.test_bytearrayobject..._import_extension of <pypy.module.cpyext.test.test_bytearrayobject.AppTestStringObject object at 0x7ff8ee98aad0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee82e950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_manipulations(): import sys module = self.import_extension('foo', [ ("bytearray_from_bytes", "METH_VARARGS", ''' return PyByteArray_FromStringAndSize(PyBytes_AsString( PyTuple_GetItem(args, 0)), 4); ''' ), ("bytes_from_bytearray", "METH_VARARGS", ''' char * buf; int n; PyObject * obj; obj = PyTuple_GetItem(args, 0); buf = PyByteArray_AsString(obj); if (buf == NULL) { PyErr_SetString(PyExc_ValueError, "non-null bytearray object expected"); return NULL; } n = PyByteArray_Size(obj); return PyBytes_FromStringAndSize(buf, n); ''' ), ("concat", "METH_VARARGS", """ PyObject * ret, *right, *left; PyObject *ba1, *ba2; if (!PyArg_ParseTuple(args, "OO", &left, &right)) { return PyUnicode_FromString("parse failed"); } ba1 = PyByteArray_FromObject(left); ba2 = PyByteArray_FromObject(right); if (ba1 == NULL || ba2 == NULL) { /* exception should be set */ return NULL; } ret = PyByteArray_Concat(ba1, ba2); return ret; """)]) assert module.bytearray_from_bytes(b"huheduwe") == b"huhe" assert module.bytes_from_bytearray(bytearray(b'abc')) == b'abc' if '__pypy__' in sys.builtin_module_names: # CPython only makes an assert. raises(ValueError, module.bytes_from_bytearray, 4.0) ret = module.concat(b'abc', b'def') assert ret == b'abcdef' assert not isinstance(ret, str) assert isinstance(ret, bytearray) raises(TypeError, module.concat, b'abc', u'def') try: test_manipulations() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestStringObject.test_bytearray_resize ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee81c350>, 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_bytearray_resize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_resize'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytearray_resize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_resize'>} 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_bytearray_resize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytearray_resize'>} 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_bytearray_resize'>, '__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 0x7ff8ee96a960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ray_resize'>, '__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 0x7ff8ee96af00> 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 0x7ff8ee96af00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ray_resize'>, '__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_bytearray_resize'>, '__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 0x7ff8ee96a320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ray_resize'>, '__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 0x7ff8ee96a050> 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 0x7ff8ee96a050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ray_resize'>, '__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_bytearray_resize'>, '__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_bytearray_resize'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytearray_resize'> 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_bytearray_resize at 0x7ff8ef3c2350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringObject.w_compile_module of <pypy.module.cpyext.test.test_bytearrayobject..._import_extension of <pypy.module.cpyext.test.test_bytearrayobject.AppTestStringObject object at 0x7ff8ee9a1710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee9c7050> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytearray_resize(): module = self.import_extension('foo', [ ("bytearray_resize", "METH_VARARGS", ''' PyObject *obj, *ba; int newsize, oldsize, ret; if (!PyArg_ParseTuple(args, "Oi", &obj, &newsize)) { return PyUnicode_FromString("parse failed"); } ba = PyByteArray_FromObject(obj); if (ba == NULL) return NULL; oldsize = PyByteArray_Size(ba); if (oldsize == 0) { return PyUnicode_FromString("oldsize is 0"); } ret = PyByteArray_Resize(ba, newsize); if (ret != 0) { printf("ret, oldsize, newsize= %d, %d, %d\\n", ret, oldsize, newsize); return NULL; } return ba; ''' )]) ret = module.bytearray_resize(b'abc', 6) assert len(ret) == 6,"%s, len=%d" % (ret, len(ret)) assert ret[:4] == b'abc\x00' ret = module.bytearray_resize(b'abcdefghi', 4) assert len(ret) == 4,"%s, len=%d" % (ret, len(ret)) assert ret == b'abcd' try: test_bytearray_resize() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestBytesObject.test_bytesobject ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7cbcd0>, 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_bytesobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytesobject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytesobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytesobject'>} 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_bytesobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytesobject'>} 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_bytesobject'>, '__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 0x7ff8ee662500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytesobject'>, '__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 0x7ff8ee6625f0> 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 0x7ff8ee6625f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytesobject'>, '__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_bytesobject'>, '__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 0x7ff8ee662690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytesobject'>, '__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 0x7ff8ee662780> 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 0x7ff8ee662780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytesobject'>, '__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_bytesobject'>, '__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_bytesobject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytesobject'> 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_bytesobject at 0x7ff8ef3d64d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee98ae50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98a210> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytesobject(): module = self.import_extension('foo', [ ("get_hello1", "METH_NOARGS", """ return PyBytes_FromStringAndSize( "Hello world<should not be included>", 11); """), ("get_hello2", "METH_NOARGS", """ return PyBytes_FromString("Hello world"); """), ("test_Size", "METH_NOARGS", """ PyObject* s = PyBytes_FromString("Hello world"); int result = PyBytes_Size(s); Py_DECREF(s); return PyLong_FromLong(result); """), ("test_Size_exception", "METH_NOARGS", """ PyObject* f = PyFloat_FromDouble(1.0); PyBytes_Size(f); Py_DECREF(f); return NULL; """), ("test_is_bytes", "METH_VARARGS", """ return PyBool_FromLong(PyBytes_Check(PyTuple_GetItem(args, 0))); """)], prologue='#include <stdlib.h>') assert module.get_hello1() == b'Hello world' assert module.get_hello2() == b'Hello world' assert module.test_Size() raises(TypeError, module.test_Size_exception) assert module.test_is_bytes(b"") assert not module.test_is_bytes(()) try: test_bytesobject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestBytesObject.test_bytes_buffer_init ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeb5b7d0>, 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_bytes_buffer_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytes_buffer_init'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytes_buffer_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytes_buffer_init'>} 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_bytes_buffer_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytes_buffer_init'>} 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_bytes_buffer_init'>, '__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 0x7ff8ef3a5370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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 0x7ff8ee96a960> 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 0x7ff8ee96a960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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_bytes_buffer_init'>, '__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 0x7ff8ee96a640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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 0x7ff8ee96af00> 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 0x7ff8ee96af00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_init'>, '__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_bytes_buffer_init'>, '__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_bytes_buffer_init'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytes_buffer_init'> 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_bytes_buffer_init at 0x7ff8ef3d6550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee98ab50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98ae90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytes_buffer_init(): module = self.import_extension('foo', [ ("getbytes", "METH_NOARGS", """ PyObject *s, *t; char* c; s = PyBytes_FromStringAndSize(NULL, 4); if (s == NULL) return NULL; t = PyBytes_FromStringAndSize(NULL, 3); if (t == NULL) return NULL; Py_DECREF(t); c = PyBytes_AS_STRING(s); c[0] = 'a'; c[1] = 'b'; c[2] = 0; c[3] = 'c'; return s; """), ]) s = module.getbytes() assert len(s) == 4 assert s == b'ab\x00c' try: test_bytes_buffer_init() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestBytesObject.test_bytes_tp_alloc ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7cbcd0>, 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_bytes_tp_alloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytes_tp_alloc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bytes_tp_alloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytes_tp_alloc'>} 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_bytes_tp_alloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bytes_tp_alloc'>} 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_bytes_tp_alloc'>, '__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 0x7ff8ee617780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_tp_alloc'>, '__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 0x7ff8ee617a00> 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 0x7ff8ee617a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_tp_alloc'>, '__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_bytes_tp_alloc'>, '__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 0x7ff8ee617af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_tp_alloc'>, '__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 0x7ff8ee617b90> 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 0x7ff8ee617b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_tp_alloc'>, '__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_bytes_tp_alloc'>, '__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_bytes_tp_alloc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bytes_tp_alloc'> 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_bytes_tp_alloc at 0x7ff8ef3d65d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee994c90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee994fd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bytes_tp_alloc(): module = self.import_extension('foo', [ ("tpalloc", "METH_NOARGS", """ PyObject *base; PyTypeObject * type; PyObject *obj; base = PyBytes_FromString("test"); if (PyBytes_GET_SIZE(base) != 4) return PyLong_FromLong(-PyBytes_GET_SIZE(base)); type = base->ob_type; if (type->tp_itemsize != 1) return PyLong_FromLong(type->tp_itemsize); obj = type->tp_alloc(type, 10); if (PyBytes_GET_SIZE(obj) != 10) return PyLong_FromLong(PyBytes_GET_SIZE(obj)); /* cannot work, there is only RO access memcpy(PyBytes_AS_STRING(obj), "works", 6); */ Py_INCREF(obj); return obj; """), ('alloc_rw', "METH_NOARGS", ''' PyObject *obj = (PyObject*)_PyObject_NewVar(&PyBytes_Type, 10); memcpy(PyBytes_AS_STRING(obj), "works", 6); return (PyObject*)obj; '''), ]) s = module.alloc_rw() assert s[:6] == b'works\0' # s[6:10] contains random garbage s = module.tpalloc() assert s == b'\x00' * 10 try: test_bytes_tp_alloc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestBytesObject.test_AsString _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7ae5d0>, 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_AsString'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsString'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_AsString'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsString'>} 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_AsString'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsString'>} 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_AsString'>, '__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 0x7ff8ee760f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsString'>, '__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 0x7ff8ee7605a0> 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 0x7ff8ee7605a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsString'>, '__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_AsString'>, '__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 0x7ff8ee760a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsString'>, '__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 0x7ff8ee760550> 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 0x7ff8ee760550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsString'>, '__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_AsString'>, '__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_AsString'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_AsString'> 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_AsString at 0x7ff8ef3d6650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee994cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98a910> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_AsString(): module = self.import_extension('foo', [ ("getbytes", "METH_NOARGS", """ char *c; PyObject* s2, *s1 = PyBytes_FromStringAndSize("test", 4); c = PyBytes_AsString(s1); s2 = PyBytes_FromStringAndSize(c, 4); Py_DECREF(s1); return s2; """), ]) s = module.getbytes() assert s == b'test' try: test_AsString() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestBytesObject.test_manipulations _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee74b2d0>, 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_manipulations'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_manipulations'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_manipulations'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_manipulations'>} 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_manipulations'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_manipulations'>} 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_manipulations'>, '__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 0x7ff8ee6167d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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 0x7ff8ee616a50> 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 0x7ff8ee616a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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_manipulations'>, '__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 0x7ff8ee616b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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 0x7ff8ee616be0> 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 0x7ff8ee616be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ipulations'>, '__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_manipulations'>, '__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_manipulations'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_manipulations'> 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_manipulations at 0x7ff8ef3d66d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee9a1b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98a3d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_manipulations(): module = self.import_extension('foo', [ ("bytes_as_string", "METH_VARARGS", ''' return PyBytes_FromStringAndSize(PyBytes_AsString( PyTuple_GetItem(args, 0)), 4); ''' ), ("concat", "METH_VARARGS", """ PyObject ** v; PyObject * left = PyTuple_GetItem(args, 0); Py_INCREF(left); /* the reference will be stolen! */ v = &left; PyBytes_Concat(v, PyTuple_GetItem(args, 1)); return *v; """)]) assert module.bytes_as_string(b"huheduwe") == b"huhe" ret = module.concat(b'abc', b'def') assert ret == b'abcdef' try: test_manipulations() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestBytesObject.test_py_bytes_as_string_None ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee75c1d0>, 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_py_bytes_as_string_None'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_py_bytes_as_string_None'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_py_bytes_as_string_None'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_py_bytes_as_string_None'>} 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_py_bytes_as_string_None'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_py_bytes_as_string_None'>} 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_py_bytes_as_string_None'>, '__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 0x7ff8ee617d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tring_None'>, '__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 0x7ff8ee6178c0> 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 0x7ff8ee6178c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tring_None'>, '__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_py_bytes_as_string_None'>, '__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 0x7ff8ee617a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tring_None'>, '__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 0x7ff8ee617b90> 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 0x7ff8ee617b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tring_None'>, '__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_py_bytes_as_string_None'>, '__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_py_bytes_as_string_None'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_py_bytes_as_string_None'> 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_py_bytes_as_string_None at 0x7ff8ef3d6750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8eeaefa90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eeaefd90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_py_bytes_as_string_None(): module = self.import_extension('foo', [ ("string_None", "METH_VARARGS", ''' if (PyBytes_AsString(Py_None)) { Py_RETURN_NONE; } return NULL; ''' )]) raises(TypeError, module.string_None) try: test_py_bytes_as_string_None() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestBytesObject.test_AsStringAndSize ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee74bcd0>, 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_AsStringAndSize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsStringAndSize'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_AsStringAndSize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsStringAndSize'>} 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_AsStringAndSize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsStringAndSize'>} 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_AsStringAndSize'>, '__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 0x7ff8ee63aaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ingAndSize'>, '__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 0x7ff8ee63ab90> 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 0x7ff8ee63ab90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ingAndSize'>, '__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_AsStringAndSize'>, '__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 0x7ff8ee63ac30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ingAndSize'>, '__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 0x7ff8ee63ad20> 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 0x7ff8ee63ad20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ingAndSize'>, '__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_AsStringAndSize'>, '__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_AsStringAndSize'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_AsStringAndSize'> 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_AsStringAndSize at 0x7ff8ef3d67d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee64f4d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee65abd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_AsStringAndSize(): module = self.import_extension('foo', [ ("getbytes", "METH_NOARGS", """ PyObject* s1 = PyBytes_FromStringAndSize("te\\0st", 5); char *buf; Py_ssize_t len; if (PyBytes_AsStringAndSize(s1, &buf, &len) < 0) return NULL; if (len != 5) { PyErr_SetString(PyExc_AssertionError, "Bad Length"); return NULL; } if (PyBytes_AsStringAndSize(s1, &buf, NULL) >= 0) { PyErr_SetString(PyExc_AssertionError, "Should Have failed"); return NULL; } PyErr_Clear(); Py_DECREF(s1); Py_INCREF(Py_None); return Py_None; """), ("c_only", "METH_NOARGS", """ int ret; char * buf2; PyObject * obj = PyBytes_FromStringAndSize(NULL, 1024); if (!obj) return NULL; buf2 = PyBytes_AsString(obj); if (!buf2) return NULL; /* buf should not have been forced, issue #2395 */ ret = _PyBytes_Resize(&obj, 512); if (ret < 0) return NULL; Py_DECREF(obj); Py_INCREF(Py_None); return Py_None; """), ]) module.getbytes() module.c_only() try: test_AsStringAndSize() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestBytesObject.test_FromFormat ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee75c1d0>, 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_FromFormat'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromFormat'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_FromFormat'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromFormat'>} 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_FromFormat'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromFormat'>} 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_FromFormat'>, '__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 0x7ff8ee5d4690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromFormat'>, '__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 0x7ff8ee5d4910> 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 0x7ff8ee5d4910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromFormat'>, '__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_FromFormat'>, '__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 0x7ff8ee5d4a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromFormat'>, '__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 0x7ff8ee5d4aa0> 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 0x7ff8ee5d4aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromFormat'>, '__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_FromFormat'>, '__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_FromFormat'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_FromFormat'> 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_FromFormat at 0x7ff8ef3d6850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee603d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee603b50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_FromFormat(): module = self.import_extension('foo', [ ("fmt", "METH_VARARGS", """ PyObject* fmt = PyTuple_GetItem(args, 0); int n = PyLong_AsLong(PyTuple_GetItem(args, 1)); PyObject* result = PyBytes_FromFormat(PyBytes_AsString(fmt), n); return result; """), ]) print(module.fmt(b'd:%d', 10)) assert module.fmt(b'd:%d', 10) == b'd:10' try: test_FromFormat() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestBytesObject.test_suboffsets ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7ae350>, 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_suboffsets'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_suboffsets'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_suboffsets'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_suboffsets'>} 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_suboffsets'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_suboffsets'>} 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_suboffsets'>, '__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 0x7ff8ef3b7050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...suboffsets'>, '__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 0x7ff8ee7ef320> 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 0x7ff8ee7ef320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...suboffsets'>, '__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_suboffsets'>, '__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 0x7ff8ee7ef7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...suboffsets'>, '__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 0x7ff8ee6dc7d0> 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 0x7ff8ee6dc7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...suboffsets'>, '__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_suboffsets'>, '__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_suboffsets'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_suboffsets'> 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_suboffsets at 0x7ff8ef3d68d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBytesObject.w_compile_module of <pypy.module.cpyext.test.test_bytesobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_bytesobject.AppTestBytesObject object at 0x7ff8ee62e490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee62e1d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_suboffsets(): module = self.import_extension('foo', [ ("check_suboffsets", "METH_O", """ Py_buffer view; PyObject_GetBuffer(args, &view, 0); return PyLong_FromLong(view.suboffsets == NULL); """)]) assert module.check_suboffsets(b'1234') == 1 try: test_suboffsets() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestCapsule.test_capsule_import ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee74b2d0>, 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_capsule_import'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_import'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_capsule_import'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_import'>} 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_capsule_import'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_import'>} 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_capsule_import'>, '__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 0x7ff8ee5cf6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ule_import'>, '__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 0x7ff8ee5cf7d0> 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 0x7ff8ee5cf7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ule_import'>, '__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_capsule_import'>, '__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 0x7ff8ee5cf870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ule_import'>, '__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 0x7ff8ee5cf960> 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 0x7ff8ee5cf960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ule_import'>, '__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_capsule_import'>, '__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_capsule_import'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_capsule_import'> 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_capsule_import at 0x7ff8ef3ef3d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCapsule.w_compile_module of <pypy.module.cpyext.test.test_capsule.AppTestCapsu...TestCapsule.w_import_extension of <pypy.module.cpyext.test.test_capsule.AppTestCapsule object at 0x7ff8ee65acd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee98a510> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_capsule_import(): module = self.import_extension('foo', [ ("set_ptr", "METH_O", """ PyObject *capsule, *module; void *ptr = PyLong_AsVoidPtr(args); if (PyErr_Occurred()) return NULL; capsule = PyCapsule_New(ptr, "foo._ptr", NULL); if (PyErr_Occurred()) return NULL; module = PyImport_ImportModule("foo"); PyModule_AddObject(module, "_ptr", capsule); Py_DECREF(module); if (PyErr_Occurred()) return NULL; Py_RETURN_NONE; """), ("get_ptr", "METH_NOARGS", """ void *ptr = PyCapsule_Import("foo._ptr", 0); if (PyErr_Occurred()) return NULL; return PyLong_FromVoidPtr(ptr); """)]) module.set_ptr(1234) assert 'capsule object "foo._ptr" at ' in str(module._ptr) import gc; gc.collect() assert module.get_ptr() == 1234 del module._ptr try: test_capsule_import() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestCapsule.test_capsule_set ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee657ed0>, 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_capsule_set'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_set'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_capsule_set'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_set'>} 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_capsule_set'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_set'>} 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_capsule_set'>, '__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 0x7ff8ee6bb2d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...apsule_set'>, '__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 0x7ff8ee6bb0a0> 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 0x7ff8ee6bb0a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...apsule_set'>, '__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_capsule_set'>, '__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 0x7ff8ee6bbfa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...apsule_set'>, '__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 0x7ff8ee5cf5f0> 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 0x7ff8ee5cf5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...apsule_set'>, '__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_capsule_set'>, '__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_capsule_set'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_capsule_set'> 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_capsule_set at 0x7ff8ef3ef450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCapsule.w_compile_module of <pypy.module.cpyext.test.test_capsule.AppTestCapsu...TestCapsule.w_import_extension of <pypy.module.cpyext.test.test_capsule.AppTestCapsule object at 0x7ff8ee603190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee603b50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_capsule_set(): # taken from _testcapimodule.c module = self.import_extension('foo', [ ("test_capsule", "METH_NOARGS", """ PyObject *object; const char *error = NULL; char *known = "known"; #define FAIL(x) { error = (x); goto exit; } #define CHECK_DESTRUCTOR \\ PyGC_Collect(); \\ PyGC_Collect(); \\ PyGC_Collect(); \\ if (capsule_error) { \\ FAIL(capsule_error); \\ } \\ else if (!capsule_destructor_call_count) { \\ FAIL("destructor not called!"); \\ } \\ capsule_destructor_call_count = 0; object = PyCapsule_New(capsule_pointer, capsule_name, capsule_destructor); PyCapsule_SetContext(object, capsule_context); capsule_destructor(object); CHECK_DESTRUCTOR; Py_DECREF(object); CHECK_DESTRUCTOR; object = PyCapsule_New(known, "ignored", NULL); PyCapsule_SetPointer(object, capsule_pointer); PyCapsule_SetName(object, capsule_name); PyCapsule_SetDestructor(object, capsule_destructor); PyCapsule_SetContext(object, capsule_context); capsule_destructor(object); CHECK_DESTRUCTOR; /* intentionally access using the wrong name */ void *pointer2 = PyCapsule_GetPointer(object, "the wrong name"); if (!PyErr_Occurred()) { FAIL("PyCapsule_GetPointer should have failed but did not!"); } PyErr_Clear(); if (pointer2) { if (pointer2 == capsule_pointer) { FAIL("PyCapsule_GetPointer should not have" " returned the internal pointer!"); } else { FAIL("PyCapsule_GetPointer should have " "returned NULL pointer but did not!"); } } PyCapsule_SetDestructor(object, NULL); Py_DECREF(object); if (capsule_destructor_call_count) { FAIL("destructor called when it should not have been!"); } exit: if (error) { PyErr_Format(PyExc_RuntimeError, "test_capsule: %s", error); return NULL; } Py_RETURN_NONE; #undef FAIL """), ], prologue=""" #include <Python.h> /* Coverage testing of capsule objects. */ static const char *capsule_name = "capsule name"; static char *capsule_pointer = "capsule pointer"; static char *capsule_context = "capsule context"; static const char *capsule_error = NULL; static int capsule_destructor_call_count = 0; static void capsule_destructor(PyObject *o) { capsule_destructor_call_count++; if (PyCapsule_GetContext(o) != capsule_context) { capsule_error = "context did not match in destructor!"; } else if (PyCapsule_GetDestructor(o) != capsule_destructor) { capsule_error = "destructor did not match in destructor! (woah!)"; } else if (PyCapsule_GetName(o) != capsule_name) { capsule_error = "name did not match in destructor!"; } else if (PyCapsule_GetPointer(o, capsule_name) != capsule_pointer) { capsule_error = "pointer did not match in destructor!"; } } """ ) module.test_capsule() try: test_capsule_set() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________ AppTestCapsule.test_capsule_destructor_via_gc_collect _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee75c1d0>, 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_capsule_destructor_via_gc_colle...__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_destructor_via_gc_collect'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_capsule_destructor_via_gc_colle...__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_destructor_via_gc_collect'>} 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_capsule_destructor_via_gc_colle...__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_capsule_destructor_via_gc_collect'>} 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_capsule_destructor_via_gc_collect'>, '__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 0x7ff8ee70f780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gc_collect'>, '__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 0x7ff8ee70fe60> 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 0x7ff8ee70fe60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gc_collect'>, '__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_capsule_destructor_via_gc_collect'>, '__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 0x7ff8ee70faa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gc_collect'>, '__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 0x7ff8ee6ae730> 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 0x7ff8ee6ae730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gc_collect'>, '__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_capsule_destructor_via_gc_collect'>, '__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_capsule_destructor_via_gc_collect'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_capsule_destructor_via_gc_collect'> 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_capsule_destructor_via_gc_collect at 0x7ff8ef3ef4d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCapsule.w_compile_module of <pypy.module.cpyext.test.test_capsule.AppTestCapsu...TestCapsule.w_import_extension of <pypy.module.cpyext.test.test_capsule.AppTestCapsule object at 0x7ff8ee603750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee627350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_capsule_destructor_via_gc_collect(): # Like test_capsule_set but the C code calls PyGC_Collect() directly # instead of going through Python's gc.collect. This mirrors what # _testcapimodule.c does in its test_capsule() function. # On CPython, Py_DECREF immediately calls tp_dealloc so PyGC_Collect # is a no-op for refcounted objects. On PyPy, PyGC_Collect() must # trigger rawrefcount collection for the destructor to be called. module = self.import_extension('foo_cap_gc', [ ("test_capsule_gc", "METH_NOARGS", """ PyObject *object; const char *error = NULL; #define FAIL(x) { error = (x); goto exit; } #define CHECK_DESTRUCTOR \\ PyGC_Collect(); \\ PyGC_Collect(); \\ if (cap_error) { \\ FAIL(cap_error); \\ } \\ else if (!cap_destructor_count) { \\ FAIL("destructor not called!"); \\ } \\ cap_destructor_count = 0; object = PyCapsule_New(cap_pointer, cap_name, cap_destructor); PyCapsule_SetContext(object, cap_context); cap_destructor(object); CHECK_DESTRUCTOR; Py_DECREF(object); CHECK_DESTRUCTOR; object = PyCapsule_New(cap_pointer, "ignored", NULL); PyCapsule_SetPointer(object, cap_pointer); PyCapsule_SetName(object, cap_name); PyCapsule_SetDestructor(object, cap_destructor); PyCapsule_SetContext(object, cap_context); cap_destructor(object); CHECK_DESTRUCTOR; PyCapsule_SetDestructor(object, NULL); Py_DECREF(object); if (cap_destructor_count) { FAIL("destructor called when it should not have been!"); } exit: if (error) { PyErr_Format(PyExc_RuntimeError, "test_capsule: %s", error); return NULL; } Py_RETURN_NONE; #undef FAIL #undef CHECK_DESTRUCTOR """), ], prologue=""" #include <Python.h> static const char *cap_name = "capsule name"; static char *cap_pointer = "capsule pointer"; static char *cap_context = "capsule context"; static const char *cap_error = NULL; static int cap_destructor_count = 0; static void cap_destructor(PyObject *o) { cap_destructor_count++; if (PyCapsule_GetContext(o) != cap_context) { cap_error = "context did not match in destructor!"; } else if (PyCapsule_GetDestructor(o) != cap_destructor) { cap_error = "destructor did not match in destructor! (woah!)"; } else if (PyCapsule_GetName(o) != cap_name) { cap_error = "name did not match in destructor!"; } else if (PyCapsule_GetPointer(o, cap_name) != cap_pointer) { cap_error = "pointer did not match in destructor!"; } } """) module.test_capsule_gc() try: test_capsule_destructor_via_gc_collect() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestCell.test_cell_type __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee663650>, 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_cell_type'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_cell_type'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_cell_type'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_cell_type'>} 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_cell_type'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_cell_type'>} 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_cell_type'>, '__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 0x7ff8ee72a460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._cell_type'>, '__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 0x7ff8ee72a730> 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 0x7ff8ee72a730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._cell_type'>, '__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_cell_type'>, '__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 0x7ff8ee72a780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._cell_type'>, '__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 0x7ff8ee72ad20> 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 0x7ff8ee72ad20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._cell_type'>, '__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_cell_type'>, '__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_cell_type'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_cell_type'> 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_cell_type at 0x7ff8ef3fa1d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCell.w_compile_module of <pypy.module.cpyext.test.test_cell.AppTestCell object...ethod AppTestCell.w_import_extension of <pypy.module.cpyext.test.test_cell.AppTestCell object at 0x7ff8ee627990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee65aa10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_cell_type(): module = self.import_extension('foo', [ ("cell_type", "METH_O", """ PyDict_SetItemString(args, "cell", (PyObject*)&PyCell_Type); Py_RETURN_NONE; """)]) d = {} module.cell_type(d) def f(o): def g(): return o return g cell_type = type(f(0).__closure__[0]) assert d["cell"] is cell_type try: test_cell_type() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestInstanceMethod.test_instancemethod ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee99f7d0>, 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_instancemethod'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_instancemethod'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_instancemethod'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_instancemethod'>} 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_instancemethod'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_instancemethod'>} 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_instancemethod'>, '__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 0x7ff8ee5cf0f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ancemethod'>, '__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 0x7ff8ee5cf320> 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 0x7ff8ee5cf320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ancemethod'>, '__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_instancemethod'>, '__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 0x7ff8ee5cf3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ancemethod'>, '__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 0x7ff8ee5cff50> 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 0x7ff8ee5cff50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ancemethod'>, '__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_instancemethod'>, '__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_instancemethod'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_instancemethod'> 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_instancemethod at 0x7ff8ef3fa8d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestInstanceMethod.w_compile_module of <pypy.module.cpyext.test.test_classobject.A....w_import_extension of <pypy.module.cpyext.test.test_classobject.AppTestInstanceMethod object at 0x7ff8ee9b55d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee676bd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_instancemethod(): module = self.import_extension('foo', [ ("instancemethod", "METH_O", """ return PyInstanceMethod_New(args); """)]) def testfunction(self): """some doc""" return self class InstanceMethod: id = module.instancemethod(id) testmethod = module.instancemethod(testfunction) inst = InstanceMethod() assert id(inst) == inst.id() assert inst.testmethod() is inst assert InstanceMethod.testmethod(inst) is inst assert InstanceMethod.__dict__['testmethod'](inst) is inst assert inst.testmethod.__doc__ == testfunction.__doc__ assert InstanceMethod.testmethod.__doc__ == testfunction.__doc__ InstanceMethod.testmethod.attribute = "test" assert testfunction.attribute == "test" raises(AttributeError, setattr, inst.testmethod, "attribute", "test") try: test_instancemethod() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________ AppTestInstanceMethod.test_instancemethod_cpyext_attributes __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee73b1d0>, 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_instancemethod_cpyext_attribute...l__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_instancemethod_cpyext_attributes'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_instancemethod_cpyext_attribute...l__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_instancemethod_cpyext_attributes'>} 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_instancemethod_cpyext_attribute...l__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_instancemethod_cpyext_attributes'>} 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_instancemethod_cpyext_attributes'>, '__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 0x7ff8ee5ad640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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 0x7ff8ee5ad8c0> 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 0x7ff8ee5ad8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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_instancemethod_cpyext_attributes'>, '__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 0x7ff8ee5ad9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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 0x7ff8ee5ada50> 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 0x7ff8ee5ada50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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_instancemethod_cpyext_attributes'>, '__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_instancemethod_cpyext_attributes'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_instancemethod_cpyext_attributes'> 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_instancemethod_cpyext_attributes at 0x7ff8ef3fa950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestInstanceMethod.w_compile_module of <pypy.module.cpyext.test.test_classobject.A....w_import_extension of <pypy.module.cpyext.test.test_classobject.AppTestInstanceMethod object at 0x7ff8ee5cce90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5ccb50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_instancemethod_cpyext_attributes(): module = self.import_extension('foo', [ ("instancemethod_get_doc", "METH_O", """ PyObject* instancemethod = PyInstanceMethod_New(args); return PyObject_GetAttrString(instancemethod, "__doc__"); """), ("instancemethod_get_name", "METH_O", """ PyObject* instancemethod = PyInstanceMethod_New(args); return PyObject_GetAttrString(instancemethod, "__name__"); """), ("instancemethod_get_module", "METH_O", """ PyObject* instancemethod = PyInstanceMethod_New(args); return PyObject_GetAttrString(instancemethod, "__module__"); """) ]) def testfunction(self): """some doc""" return self assert(module.instancemethod_get_doc(testfunction) == testfunction.__doc__) assert(module.instancemethod_get_module(testfunction) == testfunction.__module__) assert(module.instancemethod_get_name(testfunction) == testfunction.__name__) try: test_instancemethod_cpyext_attributes() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestUnicodeObject.test_encode_decode ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee99f9d0>, 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_encode_decode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_encode_decode'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_encode_decode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_encode_decode'>} 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_encode_decode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_encode_decode'>} 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_encode_decode'>, '__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 0x7ff8ee69ad70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ode_decode'>, '__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 0x7ff8ee69a320> 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 0x7ff8ee69a320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ode_decode'>, '__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_encode_decode'>, '__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 0x7ff8ee69ae10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ode_decode'>, '__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 0x7ff8ee69a7d0> 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 0x7ff8ee69a7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ode_decode'>, '__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_encode_decode'>, '__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_encode_decode'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_encode_decode'> 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_encode_decode at 0x7ff8ef3f8dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestUnicodeObject.w_compile_module of <pypy.module.cpyext.test.test_codecs.AppTest...Object.w_import_extension of <pypy.module.cpyext.test.test_codecs.AppTestUnicodeObject object at 0x7ff8ee5e1050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5e1e90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_encode_decode(): module = self.import_extension('foo', [ ("encode", "METH_VARARGS", """ PyObject *obj=NULL; const char *encoding=NULL; const char *errors=NULL; if (!PyArg_ParseTuple(args, "Os|s:foo.encode", &obj, &encoding, &errors)) return NULL; return PyCodec_Encode(obj, encoding, errors); """), ("decode", "METH_VARARGS", """ PyObject *obj=NULL; const char *encoding=NULL; const char *errors=NULL; if (!PyArg_ParseTuple(args, "Os|s:foo.decode", &obj, &encoding, &errors)) return NULL; return PyCodec_Decode(obj, encoding, errors); """),]) assert module.decode(b'abc', 'latin-1') == 'abc' assert module.encode('abc', 'latin-1') == b'abc' assert module.decode(b'abc', 'latin-1', 'strict') == 'abc' assert module.encode('abc', 'latin-1', 'strict') == b'abc' try: test_encode_decode() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestCComplex.test_AsCComplex ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee9a4bd0>, 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_AsCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsCComplex'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_AsCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsCComplex'>} 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_AsCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AsCComplex'>} 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_AsCComplex'>, '__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 0x7ff8ee63a5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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 0x7ff8ee63a5f0> 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 0x7ff8ee63a5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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_AsCComplex'>, '__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 0x7ff8ee5ad4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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 0x7ff8ee5ad780> 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 0x7ff8ee5ad780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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_AsCComplex'>, '__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_AsCComplex'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_AsCComplex'> 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_AsCComplex at 0x7ff8ef316bd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCComplex.w_compile_module of <pypy.module.cpyext.test.test_complexobject.AppTe...plex.w_import_extension of <pypy.module.cpyext.test.test_complexobject.AppTestCComplex object at 0x7ff8ee962e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee962310> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_AsCComplex(): module = self.import_extension('foo', [ ("as_tuple", "METH_O", """ Py_complex c = PyComplex_AsCComplex(args); if (PyErr_Occurred()) return NULL; return Py_BuildValue("dd", c.real, c.imag); """)]) assert module.as_tuple(12-34j) == (12, -34) assert module.as_tuple(-3.14) == (-3.14, 0.0) raises(TypeError, module.as_tuple, "12") try: test_AsCComplex() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestCComplex.test_FromCComplex _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee99f9d0>, 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_FromCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromCComplex'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_FromCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromCComplex'>} 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_FromCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromCComplex'>} 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_FromCComplex'>, '__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 0x7ff8ee5505f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omCComplex'>, '__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 0x7ff8ee5506e0> 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 0x7ff8ee5506e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omCComplex'>, '__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_FromCComplex'>, '__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 0x7ff8ee550780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omCComplex'>, '__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 0x7ff8ee550870> 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 0x7ff8ee550870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omCComplex'>, '__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_FromCComplex'>, '__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_FromCComplex'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_FromCComplex'> 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_FromCComplex at 0x7ff8ef316c50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCComplex.w_compile_module of <pypy.module.cpyext.test.test_complexobject.AppTe...plex.w_import_extension of <pypy.module.cpyext.test.test_complexobject.AppTestCComplex object at 0x7ff8ee676290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5d1710> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_FromCComplex(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ Py_complex c = {1.2, 3.4}; return PyComplex_FromCComplex(c); """)]) assert module.test() == 1.2 + 3.4j try: test_FromCComplex() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCComplex.test_PyComplex_to_WComplex __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee9a4bd0>, 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_PyComplex_to_WComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyComplex_to_WComplex'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyComplex_to_WComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyComplex_to_WComplex'>} 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_PyComplex_to_WComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyComplex_to_WComplex'>} 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_PyComplex_to_WComplex'>, '__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 0x7ff8ee5ad0a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...o_WComplex'>, '__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 0x7ff8ee5d25f0> 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 0x7ff8ee5d25f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...o_WComplex'>, '__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_PyComplex_to_WComplex'>, '__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 0x7ff8ee5d2730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...o_WComplex'>, '__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 0x7ff8ee5d2960> 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 0x7ff8ee5d2960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...o_WComplex'>, '__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_PyComplex_to_WComplex'>, '__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_PyComplex_to_WComplex'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyComplex_to_WComplex'> 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_PyComplex_to_WComplex at 0x7ff8ef316cd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCComplex.w_compile_module of <pypy.module.cpyext.test.test_complexobject.AppTe...plex.w_import_extension of <pypy.module.cpyext.test.test_complexobject.AppTestCComplex object at 0x7ff8ee5bf1d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5bfc50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyComplex_to_WComplex(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ Py_complex c = {1.2, 3.4}; PyObject *obj = PyObject_Malloc(sizeof(PyComplexObject)); obj = PyObject_Init(obj, &PyComplex_Type); assert(obj != NULL); ((PyComplexObject *)obj)->cval = c; return obj; """)]) assert module.test() == 1.2 + 3.4j try: test_PyComplex_to_WComplex() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCComplex.test_WComplex_to_PyComplex __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7a6dd0>, 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_WComplex_to_PyComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_WComplex_to_PyComplex'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_WComplex_to_PyComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_WComplex_to_PyComplex'>} 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_WComplex_to_PyComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_WComplex_to_PyComplex'>} 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_WComplex_to_PyComplex'>, '__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 0x7ff8ee56f7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyComplex'>, '__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 0x7ff8ee56f8c0> 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 0x7ff8ee56f8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyComplex'>, '__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_WComplex_to_PyComplex'>, '__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 0x7ff8ee56f960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyComplex'>, '__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 0x7ff8ee56fa50> 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 0x7ff8ee56fa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyComplex'>, '__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_WComplex_to_PyComplex'>, '__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_WComplex_to_PyComplex'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_WComplex_to_PyComplex'> 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_WComplex_to_PyComplex at 0x7ff8ef316d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCComplex.w_compile_module of <pypy.module.cpyext.test.test_complexobject.AppTe...plex.w_import_extension of <pypy.module.cpyext.test.test_complexobject.AppTestCComplex object at 0x7ff8ee676550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5bf7d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_WComplex_to_PyComplex(): module = self.import_extension('foo', [ ("test", "METH_O", """ Py_complex c = ((PyComplexObject *)args)->cval; return Py_BuildValue("dd", c.real, c.imag); """)]) assert module.test(1.2 + 3.4j) == (1.2, 3.4) try: test_WComplex_to_PyComplex() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCComplex.test_PyComplex_AsCComplex ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee9a4bd0>, 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_PyComplex_AsCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyComplex_AsCComplex'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyComplex_AsCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyComplex_AsCComplex'>} 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_PyComplex_AsCComplex'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyComplex_AsCComplex'>} 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_PyComplex_AsCComplex'>, '__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 0x7ff8ee56feb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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 0x7ff8eeade8c0> 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 0x7ff8eeade8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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_PyComplex_AsCComplex'>, '__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 0x7ff8eeade550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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 0x7ff8eeade640> 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 0x7ff8eeade640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...AsCComplex'>, '__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_PyComplex_AsCComplex'>, '__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_PyComplex_AsCComplex'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyComplex_AsCComplex'> 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_PyComplex_AsCComplex at 0x7ff8ef316dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCComplex.w_compile_module of <pypy.module.cpyext.test.test_complexobject.AppTe...plex.w_import_extension of <pypy.module.cpyext.test.test_complexobject.AppTestCComplex object at 0x7ff8ee5e5f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5e52d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyComplex_AsCComplex(): module = self.import_extension('foo', [ ("test", "METH_O", """ Py_complex c = PyComplex_AsCComplex(args); if (c.real == -1. && PyErr_Occurred()) { return NULL; } return Py_BuildValue("dd", c.real, c.imag); """)]) class C(complex): def __complex__(self): return -10-10j assert module.test(complex(1 + 1j)) == (1, 1) assert complex(C(1 + 1j)) == -10-10j, C(1 + 1j) # since it is a subclass, the __complex__ is ignored. assert module.test(C(1 + 1j)) == (1, 1) try: test_PyComplex_AsCComplex() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestContext.test_context __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee9dd450>, 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_context'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_context'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_context'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_context'>} 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_context'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_context'>} 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_context'>, '__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 0x7ff8ee503870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_context'>, '__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 0x7ff8ee503960> 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 0x7ff8ee503960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_context'>, '__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_context'>, '__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 0x7ff8ee503a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_context'>, '__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 0x7ff8ee503af0> 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 0x7ff8ee503af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_context'>, '__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_context'>, '__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_context'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_context'> 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_context at 0x7ff8ef3280d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestContext.w_compile_module of <pypy.module.cpyext.test.test_contextvars.AppTestC...Context.w_import_extension of <pypy.module.cpyext.test.test_contextvars.AppTestContext object at 0x7ff8ee5a5ed0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5a5a50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_context(): module = self.import_extension('foo', [ ("new", "METH_VARARGS", ''' PyObject *obj = NULL; const char *name; if (!PyArg_ParseTuple(args, "s|O:new", &name, &obj)) { return NULL; } return PyContextVar_New(name, obj); ''' ), ("set", "METH_VARARGS", ''' PyObject *obj, *val; if (!PyArg_ParseTuple(args, "OO:set", &obj, &val)) { return NULL; } return PyContextVar_Set(obj, val); ''' ), ("reset", "METH_VARARGS", ''' PyObject *obj, *token; if (!PyArg_ParseTuple(args, "OO:reset", &obj, &token)) { return NULL; } int ret = PyContextVar_Reset(obj, token); if (ret < 0) return NULL; return PyLong_FromLong(ret); ''' ), ("get", "METH_VARARGS", ''' PyObject *obj, *def=NULL, *val; if (!PyArg_ParseTuple(args, "O|O:get", &obj, &def)) { return NULL; } if (PyContextVar_Get(obj, def, &val) < 0) { return NULL; } if (val == NULL) { Py_RETURN_NONE; } return val; ''' ), ("get_value", "METH_VARARGS", ''' /* equivalent to cython's Cython/Includes/cpython/contextvars.pxd */ PyObject *var, *value=NULL, *default_value=NULL; if (!PyArg_ParseTuple(args, "O|O:get_value", &var, &default_value)) { return NULL; } if (PyContextVar_Get(var, NULL, &value) < 0) { return NULL; } if (value == NULL) { if (default_value == NULL) Py_RETURN_NONE; Py_INCREF(default_value); return default_value; } return value; ''' ), ("get_value_no_default", "METH_VARARGS", ''' /* equivalent to cython's Cython/Includes/cpython/contextvars.pxd */ PyObject *var, *value=NULL, *default_value=NULL; if (!PyArg_ParseTuple(args, "O|O:get_value_no_default", &var, &default_value)) { return NULL; } if (PyContextVar_Get(var, default_value, &value) < 0) { return NULL; } if (value == NULL) { Py_RETURN_NONE; } return value; ''' ), ]) var = module.new("testme", 3) tok4 = module.set(var, 4) assert tok4.var is var assert module.get(var) == 4 tok5 = module.set(var, 5) assert tok5.var is var assert module.get(var) == 5 module.reset(var, tok5) assert module.get(var) == 4 # no default var = module.new("testme") five = module.get(var, 5) assert five == 5 # cython tests import contextvars pycvar = contextvars.ContextVar("pycvar") cvar = module.new("cvar") cvar_with_default = module.new("cvar_wd", "DEFAULT") assert module.get_value(cvar) is None assert module.get_value(cvar, "default") == "default" assert module.get_value(pycvar) is None assert module.get_value(pycvar, "default") == "default" assert module.get_value(cvar_with_default) == "DEFAULT" assert module.get_value(cvar_with_default, "default") == "DEFAULT" assert module.get_value_no_default(cvar) is None assert module.get_value_no_default(cvar, "default") == "default" assert module.get_value_no_default(pycvar) is None assert module.get_value_no_default(pycvar, "default") == "default" assert module.get_value_no_default(cvar_with_default) == "DEFAULT" # this is the only variant that gives a different answer ret = module.get_value_no_default(cvar_with_default, "default") print('ret', ret) assert ret == "default" try: test_context() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCpythonExtension.test_createmodule ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf450>, 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_createmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_createmodule'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_createmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_createmodule'>} 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_createmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_createmodule'>} 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_createmodule'>, '__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 0x7ff8ee6e12d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...eatemodule'>, '__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 0x7ff8ee6e1550> 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 0x7ff8ee6e1550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...eatemodule'>, '__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_createmodule'>, '__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 0x7ff8ee9d3d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...eatemodule'>, '__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 0x7ff8ee9d35f0> 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 0x7ff8ee9d35f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...eatemodule'>, '__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_createmodule'>, '__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_createmodule'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_createmodule'> 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_createmodule at 0x7ff8ef405350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5bf290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eeea92d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_createmodule(): import sys self.import_module(name='foo') assert 'foo' in sys.modules try: test_createmodule() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestCpythonExtension.test_export_function _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf4d0>, 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_export_function'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_function'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_function'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_function'>} 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_export_function'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_function'>} 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_export_function'>, '__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 0x7ff8ee503960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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 0x7ff8ee503f50> 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 0x7ff8ee503f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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_export_function'>, '__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 0x7ff8ee503410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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 0x7ff8ee9d10a0> 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 0x7ff8ee9d10a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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_export_function'>, '__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_export_function'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_function'> 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_export_function at 0x7ff8ef4053d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5a5c90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee58c750> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_function(): import sys if '__pypy__' in sys.modules: from cpyext import is_cpyext_builtin_function as is_cpyext_function else: import inspect is_cpyext_function = inspect.isbuiltin body = """ PyObject* foo_pi(PyObject* self, PyObject *args) { return PyFloat_FromDouble(3.14); } static PyMethodDef methods[] = { { "return_pi", foo_pi, METH_NOARGS }, { NULL } }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "foo", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ methods, /* m_methods */ }; """ module = self.import_module(name='foo', body=body) assert 'foo' in sys.modules assert 'return_pi' in dir(module) assert module.return_pi is not None assert is_cpyext_function(module.return_pi) assert module.return_pi() == 3.14 assert module.return_pi.__module__ == 'foo' try: test_export_function() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestCpythonExtension.test_export_docstring _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeac92d0>, 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_export_docstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_docstring'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_docstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_docstring'>} 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_export_docstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_docstring'>} 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_export_docstring'>, '__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 0x7ff8ee9d3c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._docstring'>, '__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 0x7ff8ee9d3a00> 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 0x7ff8ee9d3a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._docstring'>, '__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_export_docstring'>, '__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 0x7ff8ee9d3640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._docstring'>, '__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 0x7ff8ee9d35f0> 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 0x7ff8ee9d35f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._docstring'>, '__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_export_docstring'>, '__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_export_docstring'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_docstring'> 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_export_docstring at 0x7ff8ef405450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee58cf90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee58c950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_docstring(): body = """ PyDoc_STRVAR(foo_pi_doc, "Return pi."); PyObject* foo_pi(PyObject* self, PyObject *args) { return PyFloat_FromDouble(3.14); } static PyMethodDef methods[] = { { "return_pi", foo_pi, METH_NOARGS, foo_pi_doc }, { NULL } }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "foo", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ methods, /* m_methods */ }; """ module = self.import_module(name='foo', body=body) doc = module.return_pi.__doc__ assert doc == "Return pi." try: test_export_docstring() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCpythonExtension.test_load_dynamic ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf450>, 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_load_dynamic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_load_dynamic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_load_dynamic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_load_dynamic'>} 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_load_dynamic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_load_dynamic'>} 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_load_dynamic'>, '__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 0x7ff8ee525910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_dynamic'>, '__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 0x7ff8ee525a00> 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 0x7ff8ee525a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_dynamic'>, '__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_load_dynamic'>, '__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 0x7ff8ee525aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_dynamic'>, '__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 0x7ff8ee525b90> 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 0x7ff8ee525b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_dynamic'>, '__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_load_dynamic'>, '__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_load_dynamic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_load_dynamic'> 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_load_dynamic at 0x7ff8ef4054d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5a5fd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5a5f90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_load_dynamic(): import sys body = """ static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "%(modname)s", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ NULL, /* m_methods */ }; """ foo = self.import_module(name='foo', body=body, use_imp=True) assert 'foo' in sys.modules del sys.modules['foo'] # replaces imp.load_dynamic('foo', foo.__file__), removed in 3.12 import importlib.machinery, importlib.util loader = importlib.machinery.ExtensionFileLoader('foo', foo.__file__) spec = importlib.util.spec_from_file_location( 'foo', foo.__file__, loader=loader) foo2 = importlib.util.module_from_spec(spec) sys.modules['foo'] = foo2 loader.exec_module(foo2) assert 'foo' in sys.modules assert foo.__dict__ == foo2.__dict__ try: test_load_dynamic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestCpythonExtension.test_InitModule4_dotted ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee6b3150>, 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_InitModule4_dotted'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_InitModule4_dotted'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_InitModule4_dotted'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_InitModule4_dotted'>} 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_InitModule4_dotted'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_InitModule4_dotted'>} 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_InitModule4_dotted'>, '__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 0x7ff8ee503050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le4_dotted'>, '__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 0x7ff8ee5034b0> 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 0x7ff8ee5034b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le4_dotted'>, '__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_InitModule4_dotted'>, '__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 0x7ff8ee503320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le4_dotted'>, '__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 0x7ff8ee503190> 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 0x7ff8ee503190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le4_dotted'>, '__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_InitModule4_dotted'>, '__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_InitModule4_dotted'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_InitModule4_dotted'> 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_InitModule4_dotted at 0x7ff8ef405550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee52cb50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee52c2d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_InitModule4_dotted(): """ If the module name passed to Py_InitModule4 includes a package, only the module name (the part after the last dot) is considered when computing the name of the module initializer function. """ expected_name = "pypy.module.cpyext.test.dotted" module = self.import_module(name=expected_name, filename="dotted") assert module.__name__ == expected_name, module.__name__ try: test_InitModule4_dotted() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________ AppTestCpythonExtension.test_InitModule4_in_package ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee6861d0>, 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_InitModule4_in_package'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_InitModule4_in_package'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_InitModule4_in_package'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_InitModule4_in_package'>} 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_InitModule4_in_package'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_InitModule4_in_package'>} 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_InitModule4_in_package'>, '__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 0x7ff8ee4a46e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...in_package'>, '__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 0x7ff8ee4a4960> 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 0x7ff8ee4a4960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...in_package'>, '__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_InitModule4_in_package'>, '__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 0x7ff8ee4a4a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...in_package'>, '__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 0x7ff8ee4a4af0> 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 0x7ff8ee4a4af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...in_package'>, '__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_InitModule4_in_package'>, '__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_InitModule4_in_package'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_InitModule4_in_package'> 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_InitModule4_in_package at 0x7ff8ef4055d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5e5810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee59f6d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_InitModule4_in_package(): """ If `apple.banana` is an extension module which calls Py_InitModule4 with only "banana" as a name, the resulting module nevertheless is stored at `sys.modules["apple.banana"]`. """ module = self.import_module(name="apple.banana", filename="banana") assert module.__name__ == "apple.banana" try: test_InitModule4_in_package() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________ AppTestCpythonExtension.test_recursive_package_import _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee98f450>, 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_recursive_package_import'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_recursive_package_import'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_recursive_package_import'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_recursive_package_import'>} 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_recursive_package_import'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_recursive_package_import'>} 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_recursive_package_import'>, '__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 0x7ff8ee5034b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...age_import'>, '__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 0x7ff8ee503550> 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 0x7ff8ee503550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...age_import'>, '__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_recursive_package_import'>, '__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 0x7ff8ee503320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...age_import'>, '__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 0x7ff8ee503190> 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 0x7ff8ee503190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...age_import'>, '__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_recursive_package_import'>, '__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_recursive_package_import'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_recursive_package_import'> 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_recursive_package_import at 0x7ff8ef405650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5e5fd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee594850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_recursive_package_import(): """ If `cherry.date` is an extension module which imports `apple.banana`, the latter is added to `sys.modules` for the `"apple.banana"` key. """ import sys, types, os # Build the extensions. banana = self.compile_module( "apple.banana", source_files=[os.path.join(self.here, 'banana.c')]) date = self.compile_module( "cherry.date", source_files=[os.path.join(self.here, 'date.c')]) # Set up some package state so that the extensions can actually be # imported. cherry = sys.modules['cherry'] = types.ModuleType('cherry') cherry.__path__ = [os.path.dirname(date)] apple = sys.modules['apple'] = types.ModuleType('apple') apple.__path__ = [os.path.dirname(banana)] import cherry.date assert sys.modules['apple.banana'].__name__ == 'apple.banana' assert sys.modules['cherry.date'].__name__ == 'cherry.date' try: test_recursive_package_import() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCpythonExtension.test_modinit_func ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeac92d0>, 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_modinit_func'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_modinit_func'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_modinit_func'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_modinit_func'>} 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_modinit_func'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_modinit_func'>} 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_modinit_func'>, '__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 0x7ff8ee4a55a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dinit_func'>, '__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 0x7ff8ee4a5820> 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 0x7ff8ee4a5820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dinit_func'>, '__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_modinit_func'>, '__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 0x7ff8ee4a5910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dinit_func'>, '__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 0x7ff8ee4a59b0> 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 0x7ff8ee4a59b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...dinit_func'>, '__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_modinit_func'>, '__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_modinit_func'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_modinit_func'> 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_modinit_func at 0x7ff8ef4056d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee57bd90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee57b650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_modinit_func(): """ A module can use the PyMODINIT_FUNC macro to declare or define its module initializer function. """ module = self.import_module(name='modinit') assert module.__name__ == 'modinit' try: test_modinit_func() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestCpythonExtension.test_export_function2 _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf1d0>, 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_export_function2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_function2'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_function2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_function2'>} 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_export_function2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_function2'>} 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_export_function2'>, '__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 0x7ff8ee5ec640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._function2'>, '__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 0x7ff8ee5ec050> 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 0x7ff8ee5ec050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._function2'>, '__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_export_function2'>, '__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 0x7ff8ee5ec690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._function2'>, '__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 0x7ff8ee5ec500> 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 0x7ff8ee5ec500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._function2'>, '__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_export_function2'>, '__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_export_function2'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_function2'> 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_export_function2 at 0x7ff8ef405750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5e5650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5d5b10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_function2(): body = """ static PyObject* my_objects[1]; static PyObject* foo_cached_pi(PyObject* self, PyObject *args) { if (my_objects[0] == NULL) { my_objects[0] = PyFloat_FromDouble(3.14); } Py_INCREF(my_objects[0]); return my_objects[0]; } static PyObject* foo_drop_pi(PyObject* self, PyObject *args) { if (my_objects[0] != NULL) { Py_DECREF(my_objects[0]); my_objects[0] = NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject* foo_retinvalid(PyObject* self, PyObject *args) { return (PyObject*)0xAFFEBABE; } static PyMethodDef methods[] = { { "return_pi", foo_cached_pi, METH_NOARGS }, { "drop_pi", foo_drop_pi, METH_NOARGS }, { "return_invalid_pointer", foo_retinvalid, METH_NOARGS }, { NULL } }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "%(modname)s", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ methods, /* m_methods */ }; """ module = self.import_module(name='foo', body=body) assert module.return_pi() == 3.14 module.drop_pi() module.drop_pi() assert module.return_pi() == 3.14 assert module.return_pi() == 3.14 module.drop_pi() skip("Hmm, how to check for the exception?") raises(api.InvalidPointerException, module.return_invalid_pointer) try: test_export_function2() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestCpythonExtension.test_argument _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeaecdd0>, 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_argument'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_argument'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_argument'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_argument'>} 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_argument'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_argument'>} 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_argument'>, '__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 0x7ff8ee602190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argument'>, '__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 0x7ff8ee4a5500> 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 0x7ff8ee4a5500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argument'>, '__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_argument'>, '__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 0x7ff8ee4a5b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argument'>, '__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 0x7ff8ee4a50a0> 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 0x7ff8ee4a50a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_argument'>, '__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_argument'>, '__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_argument'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_argument'> 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_argument at 0x7ff8ef4057d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee5bf5d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee52c190> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_argument(): import sys body = """ PyObject* foo_test(PyObject* self, PyObject *args) { PyObject *t = PyTuple_GetItem(args, 0); Py_INCREF(t); return t; } static PyMethodDef methods[] = { { "test", foo_test, METH_VARARGS }, { NULL } }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "%(modname)s", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ methods, /* m_methods */ }; """ module = self.import_module(name='foo', body=body) assert module.test(True, True) == True try: test_argument() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestCpythonExtension.test_exception ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeac9050>, 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_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_exception'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_exception'>} 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_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_exception'>} 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_exception'>, '__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 0x7ff8ee6c85f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8ee525b90> 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 0x7ff8ee525b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_exception'>, '__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 0x7ff8ee525140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8ee525870> 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 0x7ff8ee525870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_exception'>, '__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_exception'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_exception'> 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_exception at 0x7ff8ef405850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee4a1f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4a1e90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_exception(): import sys body = """ static PyObject* foo_pi(PyObject* self, PyObject *args) { PyErr_SetString(PyExc_Exception, "moo!"); return NULL; } static PyMethodDef methods[] = { { "raise_exception", foo_pi, METH_NOARGS }, { NULL } }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "%(modname)s", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ methods, /* m_methods */ }; """ module = self.import_module(name='foo', body=body) exc = raises(Exception, module.raise_exception) if type(exc.value) is not Exception: raise exc.value assert str(exc.value) == "moo!" try: test_exception() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestCpythonExtension.test_refcount _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee6ed5d0>, 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_refcount'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_refcount'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_refcount'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_refcount'>} 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_refcount'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_refcount'>} 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_refcount'>, '__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 0x7ff8ee5fb820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_refcount'>, '__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 0x7ff8ee5fbeb0> 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 0x7ff8ee5fbeb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_refcount'>, '__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_refcount'>, '__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 0x7ff8ee5fb910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_refcount'>, '__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 0x7ff8ee5fbc80> 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 0x7ff8ee5fbc80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_refcount'>, '__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_refcount'>, '__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_refcount'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_refcount'> 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_refcount at 0x7ff8ef4058d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee594b90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5bf2d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_refcount(): import sys body = """ static PyObject* foo_pi(PyObject* self, PyObject *args) { PyObject *true_obj = Py_True; Py_ssize_t refcnt = true_obj->ob_refcnt; Py_ssize_t refcnt_after; Py_INCREF(true_obj); Py_INCREF(true_obj); if (!PyBool_Check(true_obj)) Py_RETURN_NONE; refcnt_after = true_obj->ob_refcnt; Py_DECREF(true_obj); Py_DECREF(true_obj); fprintf(stderr, "REFCNT %ld %ld\\n", refcnt, refcnt_after); return PyBool_FromLong(refcnt_after == refcnt + 2); } static PyObject* foo_bar(PyObject* self, PyObject *args) { PyObject *true_obj = Py_True; PyObject *tup = NULL; Py_ssize_t refcnt = true_obj->ob_refcnt; Py_ssize_t refcnt_after; tup = PyTuple_New(1); Py_INCREF(true_obj); if (PyTuple_SetItem(tup, 0, true_obj) < 0) return NULL; refcnt_after = true_obj->ob_refcnt; Py_DECREF(tup); fprintf(stderr, "REFCNT2 %ld %ld %ld\\n", refcnt, refcnt_after, true_obj->ob_refcnt); return PyBool_FromLong(refcnt_after == refcnt + 1 && refcnt == true_obj->ob_refcnt); } static PyMethodDef methods[] = { { "test_refcount", foo_pi, METH_NOARGS }, { "test_refcount2", foo_bar, METH_NOARGS }, { NULL } }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "%(modname)s", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ methods, /* m_methods */ }; """ module = self.import_module(name='foo', body=body) assert module.test_refcount() assert module.test_refcount2() try: test_refcount() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestCpythonExtension.test_init_exception __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee5a9c50>, 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_init_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_init_exception'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_init_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_init_exception'>} 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_init_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_init_exception'>} 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_init_exception'>, '__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 0x7ff8ee534410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8ee534eb0> 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 0x7ff8ee534eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_init_exception'>, '__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 0x7ff8ee534050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8ee534dc0> 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 0x7ff8ee534dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_init_exception'>, '__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_init_exception'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_init_exception'> 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_init_exception at 0x7ff8ef405950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee57b610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee5e5590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_init_exception(): import sys init = """ PyErr_SetString(PyExc_Exception, "moo!"); return NULL; """ exc = raises(Exception, self.import_module, name='foo', init=init) if type(exc.value) is not Exception: raise exc.value assert str(exc.value) == "moo!" try: test_init_exception() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCpythonExtension.test_new_exception __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee5b25d0>, 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_new_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_new_exception'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_new_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_new_exception'>} 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_new_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_new_exception'>} 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_new_exception'>, '__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 0x7ff8ee6c8cd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8ee6c8e60> 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 0x7ff8ee6c8e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_new_exception'>, '__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 0x7ff8ee6c8280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8ee6c8640> 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 0x7ff8ee6c8640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_new_exception'>, '__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_new_exception'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_new_exception'> 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_new_exception at 0x7ff8ef405a50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee496c90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee496ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_new_exception(): mod = self.import_extension('foo', [ ('newexc', 'METH_VARARGS', ''' char *name = _PyUnicode_AsString(PyTuple_GetItem(args, 0)); return PyErr_NewException(name, PyTuple_GetItem(args, 1), PyTuple_GetItem(args, 2)); ''' ), ]) raises(SystemError, mod.newexc, "name", Exception, {}) try: test_new_exception() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestCpythonExtension.test_types ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf450>, 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_types'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_types'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_types'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_types'>} 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_types'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_types'>} 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_types'>, '__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 0x7ff8ee4f9be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_types'>, '__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 0x7ff8ee4f9960> 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 0x7ff8ee4f9960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_types'>, '__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_types'>, '__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 0x7ff8ee4f9d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_types'>, '__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 0x7ff8ee4f9370> 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 0x7ff8ee4f9370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_types'>, '__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_types'>, '__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_types'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_types'> 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_types at 0x7ff8ef405b50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee49cd90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee49c410> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_types(): """test the presence of random types""" mod = self.import_extension('foo', [ ('get_names', 'METH_NOARGS', ''' /* XXX in tests, the C type is not correct */ #define NAME(type) ((PyTypeObject*)&type)->tp_name return Py_BuildValue("ssssss", NAME(PyCell_Type), NAME(PyModule_Type), NAME(PyProperty_Type), NAME(PyStaticMethod_Type), NAME(PyClassMethod_Type), NAME(PyCFunction_Type) ); ''' ), ]) assert mod.get_names() == ('cell', 'module', 'property', 'staticmethod', 'classmethod', 'builtin_function_or_method') try: test_types() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestCpythonExtension.test_get_programname _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeac9750>, 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_get_programname'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_programname'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_get_programname'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_programname'>} 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_get_programname'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_programname'>} 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_get_programname'>, '__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 0x7ff8ee4a5f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rogramname'>, '__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 0x7ff8ee4a5eb0> 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 0x7ff8ee4a5eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rogramname'>, '__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_get_programname'>, '__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 0x7ff8ee5fbc80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rogramname'>, '__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 0x7ff8ee5fb910> 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 0x7ff8ee5fb910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rogramname'>, '__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_get_programname'>, '__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_get_programname'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_get_programname'> 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_get_programname at 0x7ff8ef405bd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee57b350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee57b6d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_get_programname(): mod = self.import_extension('foo', [ ('get_programname', 'METH_NOARGS', ''' wchar_t* name1 = Py_GetProgramName(); wchar_t* name2 = Py_GetProgramName(); if (name1 != name2) Py_RETURN_FALSE; return PyUnicode_FromWideChar(name1, wcslen(name1)); ''' )], prologue='#include <wchar.h>') p = mod.get_programname() print(p) assert 'py' in p try: test_get_programname() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestCpythonExtension.test_no_double_imports ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf450>, 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_no_double_imports'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_no_double_imports'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_no_double_imports'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_no_double_imports'>} 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_no_double_imports'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_no_double_imports'>} 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_no_double_imports'>, '__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 0x7ff8ee53fe60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_imports'>, '__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 0x7ff8ee4a4410> 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 0x7ff8ee4a4410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_imports'>, '__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_no_double_imports'>, '__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 0x7ff8ee4a43c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_imports'>, '__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 0x7ff8ee58b7d0> 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 0x7ff8ee58b7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_imports'>, '__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_no_double_imports'>, '__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_no_double_imports'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_no_double_imports'> 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_no_double_imports at 0x7ff8ef405cd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee49c650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee49cc90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_no_double_imports(): import sys, os try: body = """ static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "%(modname)s", /* m_name */ NULL, /* m_doc */ -1, /* m_size */ NULL /* m_methods */ }; """ init = """ static int _imported_already = 0; FILE *f = fopen("_imported_already", "w"); fprintf(f, "imported_already: %d\\n", _imported_already); fclose(f); _imported_already = 1; return PyModule_Create(&moduledef); """ self.import_module(name='foo', init=init, body=body) assert 'foo' in sys.modules f = open('_imported_already') data = f.read() f.close() assert data == 'imported_already: 0\n' f = open('_imported_already', 'w') f.write('not again!\n') f.close() m1 = sys.modules['foo'] m2 = self.load_module(m1.__file__, name='foo') assert m1 is m2 assert m1 is sys.modules['foo'] f = open('_imported_already') data = f.read() f.close() assert data == 'not again!\n' finally: try: os.unlink('_imported_already') except OSError: pass try: test_no_double_imports() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestCpythonExtension.test_no_structmember _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7002d0>, 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_no_structmember'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_no_structmember'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_no_structmember'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_no_structmember'>} 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_no_structmember'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_no_structmember'>} 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_no_structmember'>, '__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 0x7ff8ee468550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ructmember'>, '__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 0x7ff8ee468640> 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 0x7ff8ee468640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ructmember'>, '__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_no_structmember'>, '__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 0x7ff8ee4686e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ructmember'>, '__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 0x7ff8ee4687d0> 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 0x7ff8ee4687d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ructmember'>, '__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_no_structmember'>, '__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_no_structmember'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_no_structmember'> 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_no_structmember at 0x7ff8ef405d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee495910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4957d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_no_structmember(): """structmember.h should not be included by default.""" mod = self.import_extension('foo', [ ('bar', 'METH_NOARGS', ''' /* reuse a name that is #defined in structmember.h */ int RO = 0; (void)RO; Py_RETURN_NONE; ''' ), ]) try: test_no_structmember() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestCpythonExtension.test_consistent_flags _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeaea550>, 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_consistent_flags'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_consistent_flags'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_consistent_flags'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_consistent_flags'>} 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_consistent_flags'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_consistent_flags'>} 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_consistent_flags'>, '__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 0x7ff8ee6c8fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tent_flags'>, '__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 0x7ff8ee6c8eb0> 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 0x7ff8ee6c8eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tent_flags'>, '__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_consistent_flags'>, '__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 0x7ff8ee6c8730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tent_flags'>, '__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 0x7ff8ee6c8780> 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 0x7ff8ee6c8780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tent_flags'>, '__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_consistent_flags'>, '__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_consistent_flags'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_consistent_flags'> 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_consistent_flags at 0x7ff8ef405dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee4cffd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4cff90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_consistent_flags(): import sys mod = self.import_extension('foo', [ ('test_optimize', 'METH_NOARGS', ''' return PyLong_FromLong(Py_OptimizeFlag); '''), ]) # This is intentionally set to -1 by default from missing.c # and should be set to sys.flags.optimize at startup assert mod.test_optimize() == sys.flags.optimize try: test_consistent_flags() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCpythonExtension.test_generic_type ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee409050>, 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_generic_type'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_generic_type'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_generic_type'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_generic_type'>} 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_generic_type'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_generic_type'>} 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_generic_type'>, '__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 0x7ff8ee544d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...neric_type'>, '__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 0x7ff8ee544960> 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 0x7ff8ee544960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...neric_type'>, '__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_generic_type'>, '__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 0x7ff8ee5446e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...neric_type'>, '__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 0x7ff8ee544f50> 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 0x7ff8ee544f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...neric_type'>, '__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_generic_type'>, '__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_generic_type'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_generic_type'> 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_generic_type at 0x7ff8ef405e50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCpythonExtension.w_compile_module of <pypy.module.cpyext.test.test_cpyext.AppT...ion.w_import_extension of <pypy.module.cpyext.test.test_cpyext.AppTestCpythonExtension object at 0x7ff8ee496ed0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4cfc50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_generic_type(): mod = self.import_extension('foo', [ ('is_genericalias_type', 'METH_O', """ long test = (Py_TYPE(args) == &Py_GenericAliasType); return PyLong_FromLong(test); """)]) assert mod.is_genericalias_type(tuple[int]) try: test_generic_type() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestDatetime.test_CAPI ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee7a6ed0>, 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_CAPI'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CAPI'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_CAPI'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CAPI'>} 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_CAPI'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CAPI'>} 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_CAPI'>, '__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 0x7ff8ee9dbd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_CAPI'>, '__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 0x7ff8ee5ec050> 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 0x7ff8ee5ec050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_CAPI'>, '__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_CAPI'>, '__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 0x7ff8ee442af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_CAPI'>, '__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 0x7ff8ee6c85f0> 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 0x7ff8ee6c85f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_CAPI'>, '__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_CAPI'>, '__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_CAPI'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_CAPI'> 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_CAPI at 0x7ff8ef288dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee57bd10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4bfc10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_CAPI(): module = self.import_extension('foo', [ ("get_types", "METH_NOARGS", """ PyDateTime_IMPORT; if (!PyDateTimeAPI) { PyErr_SetString(PyExc_RuntimeError, "No PyDateTimeAPI"); return NULL; } return PyTuple_Pack(5, PyDateTimeAPI->DateType, PyDateTimeAPI->DateTimeType, PyDateTimeAPI->TimeType, PyDateTimeAPI->DeltaType, PyDateTimeAPI->TZInfoType); """), ("clear_types", "METH_NOARGS", """ Py_DECREF(PyDateTimeAPI->DateType); Py_DECREF(PyDateTimeAPI->DateTimeType); Py_DECREF(PyDateTimeAPI->TimeType); Py_DECREF(PyDateTimeAPI->DeltaType); Py_DECREF(PyDateTimeAPI->TZInfoType); Py_RETURN_NONE; """ ) ], prologue='#include "datetime.h"\n') import datetime assert module.get_types() == (datetime.date, datetime.datetime, datetime.time, datetime.timedelta, datetime.tzinfo) module.clear_types() try: test_CAPI() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestDatetime.test_constructors _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eeacf450>, 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_constructors'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constructors'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_constructors'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constructors'>} 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_constructors'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_constructors'>} 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_constructors'>, '__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 0x7ff8ee42d500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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 0x7ff8ee42d6e0> 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 0x7ff8ee42d6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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_constructors'>, '__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 0x7ff8ee42d7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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 0x7ff8ee42d870> 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 0x7ff8ee42d870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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_constructors'>, '__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_constructors'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_constructors'> 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_constructors at 0x7ff8ef288e50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee47bd90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4a1090> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_constructors(): module = self.import_extension('foo', [ ("new_date", "METH_NOARGS", """ PyDateTime_IMPORT; return PyDateTimeAPI->Date_FromDate( 2000, 6, 6, PyDateTimeAPI->DateType); """), ("new_time", "METH_NOARGS", """ PyDateTime_IMPORT; return PyDateTimeAPI->Time_FromTime( 6, 6, 6, 6, Py_None, PyDateTimeAPI->TimeType); """), ("new_datetime", "METH_NOARGS", """ PyDateTime_IMPORT; return PyDateTimeAPI->DateTime_FromDateAndTime( 2000, 6, 6, 6, 6, 6, 6, Py_None, PyDateTimeAPI->DateTimeType); """), ("new_datetime_fromtimestamp", "METH_NOARGS", """ PyDateTime_IMPORT; PyObject *ts = PyFloat_FromDouble(200000.0); Py_INCREF(Py_None); PyObject *tsargs = PyTuple_Pack(2, ts, Py_None); PyObject *rv = PyDateTimeAPI->DateTime_FromTimestamp( (PyObject *)PyDateTimeAPI->DateTimeType, tsargs, NULL); Py_DECREF(tsargs); return rv; """), ("new_dt_fromts_tzinfo", "METH_O", """ PyDateTime_IMPORT; PyObject *ts = PyFloat_FromDouble(200000.0); PyObject *tsargs = PyTuple_Pack(1, ts); PyObject *tskwargs = PyDict_New(); Py_INCREF(args); PyDict_SetItemString(tskwargs, "tz", args); PyObject *rv = PyDateTimeAPI->DateTime_FromTimestamp( (PyObject *)PyDateTimeAPI->DateTimeType, tsargs, tskwargs); Py_DECREF(tsargs); Py_DECREF(tskwargs); return rv; """), ("new_date_fromtimestamp", "METH_NOARGS", """ PyDateTime_IMPORT; PyObject *ts = PyFloat_FromDouble(1430366400.0); Py_INCREF(Py_None); PyObject *tsargs = PyTuple_Pack(1, ts); PyObject *rv = PyDateTimeAPI->Date_FromTimestamp( (PyObject *)PyDateTimeAPI->DateType, tsargs); Py_DECREF(tsargs); return rv; """), ], prologue='#include "datetime.h"\n') import datetime assert module.new_date() == datetime.date(2000, 6, 6) assert module.new_time() == datetime.time(6, 6, 6, 6) assert module.new_datetime() == datetime.datetime( 2000, 6, 6, 6, 6, 6, 6) utc = datetime.timezone.utc # .fromtimestamp tests assert (module.new_datetime_fromtimestamp() == datetime.datetime.fromtimestamp(200000.0)) assert (module.new_dt_fromts_tzinfo(utc) == datetime.datetime.fromtimestamp(200000.0, tz=utc)) assert (module.new_date_fromtimestamp() == datetime.date.fromtimestamp(1430366400.0)) try: test_constructors() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestDatetime.test_timezone_constructors __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee572350>, 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_timezone_constructors'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_timezone_constructors'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_timezone_constructors'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_timezone_constructors'>} 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_timezone_constructors'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_timezone_constructors'>} 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_timezone_constructors'>, '__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 0x7ff8ee42e6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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 0x7ff8ee42e7d0> 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 0x7ff8ee42e7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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_timezone_constructors'>, '__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 0x7ff8ee42e870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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 0x7ff8ee42e960> 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 0x7ff8ee42e960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nstructors'>, '__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_timezone_constructors'>, '__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_timezone_constructors'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_timezone_constructors'> 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_timezone_constructors at 0x7ff8ef288ed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee4597d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee459210> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_timezone_constructors(): # Testing that we can build timezones via the C api module = self.import_extension('foo', [ ("new_timezone_fromoffset", "METH_NOARGS", """ PyDateTime_IMPORT; PyObject *delta = PyDelta_FromDSU(0, 60 * 60, 0); PyObject *tzinfo = PyTimeZone_FromOffset(delta); Py_DECREF(delta); return tzinfo; """), ("new_timezone_fromoffset_and_name", "METH_NOARGS", """ PyDateTime_IMPORT; PyObject *delta = PyDelta_FromDSU(0, 60 * 60, 0); PyObject *name = PyUnicode_FromString("spam"); PyObject *tzinfo = PyTimeZone_FromOffsetAndName(delta, name); Py_DECREF(delta); Py_DECREF(name); return tzinfo; """), ("utc_singleton_access", "METH_NOARGS", """ PyDateTime_IMPORT; Py_INCREF(PyDateTime_TimeZone_UTC); return PyDateTime_TimeZone_UTC; """), ], prologue='#include "datetime.h"\n') import datetime one_hour = datetime.timedelta(hours=1) expected = datetime.timezone(one_hour) assert module.new_timezone_fromoffset() == expected expected = datetime.timezone(one_hour, "spam") assert module.new_timezone_fromoffset_and_name() == expected assert module.utc_singleton_access() == datetime.timezone.utc try: test_timezone_constructors() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestDatetime.test_macros __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee6216d0>, 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_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macros'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macros'>} 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_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macros'>} 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_macros'>, '__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 0x7ff8ee4428c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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 0x7ff8ee442be0> 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 0x7ff8ee442be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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_macros'>, '__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 0x7ff8ee4717d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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 0x7ff8ee471410> 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 0x7ff8ee471410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_macros'>, '__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_macros'>, '__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_macros'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_macros'> 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_macros at 0x7ff8ef288f50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee47b810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee47b790> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_macros(): module = self.import_extension('foo', [ ("test_date_macros", "METH_NOARGS", """ PyObject* obj; PyDateTime_Date* d; PyDateTime_IMPORT; if (!PyDateTimeAPI) { PyErr_SetString(PyExc_RuntimeError, "No PyDateTimeAPI"); return NULL; } obj = PyDate_FromDate(2000, 6, 6); d = (PyDateTime_Date*)obj; PyDateTime_GET_YEAR(obj); PyDateTime_GET_YEAR(d); PyDateTime_GET_MONTH(obj); PyDateTime_GET_MONTH(d); PyDateTime_GET_DAY(obj); PyDateTime_GET_DAY(d); return obj; """), ("test_datetime_macros", "METH_NOARGS", """ PyObject* obj; PyDateTime_DateTime *dt; PyDateTime_IMPORT; if (!PyDateTimeAPI) { PyErr_SetString(PyExc_RuntimeError, "No PyDateTimeAPI"); return NULL; } obj = PyDateTime_FromDateAndTime(2000, 6, 6, 6, 6, 6, 6); dt = (PyDateTime_DateTime*)obj; PyDateTime_GET_YEAR(obj); PyDateTime_GET_YEAR(dt); PyDateTime_GET_MONTH(obj); PyDateTime_GET_MONTH(dt); PyDateTime_GET_DAY(obj); PyDateTime_GET_DAY(dt); PyDateTime_DATE_GET_HOUR(obj); PyDateTime_DATE_GET_HOUR(dt); PyDateTime_DATE_GET_MINUTE(obj); PyDateTime_DATE_GET_MINUTE(dt); PyDateTime_DATE_GET_SECOND(obj); PyDateTime_DATE_GET_SECOND(dt); PyDateTime_DATE_GET_MICROSECOND(obj); PyDateTime_DATE_GET_MICROSECOND(dt); PyDateTime_GET_FOLD(obj); PyDateTime_DATE_GET_FOLD(obj); return obj; """), ("test_time_macros", "METH_NOARGS", """ PyObject* obj; PyDateTime_Time* t; PyDateTime_IMPORT; if (!PyDateTimeAPI) { PyErr_SetString(PyExc_RuntimeError, "No PyDateTimeAPI"); return NULL; } obj = PyTime_FromTime(6, 6, 6, 6); t = (PyDateTime_Time*)obj; PyDateTime_TIME_GET_HOUR(obj); PyDateTime_TIME_GET_HOUR(t); PyDateTime_TIME_GET_MINUTE(obj); PyDateTime_TIME_GET_MINUTE(t); PyDateTime_TIME_GET_SECOND(obj); PyDateTime_TIME_GET_SECOND(t); PyDateTime_TIME_GET_MICROSECOND(obj); PyDateTime_TIME_GET_MICROSECOND(t); return obj; """), ("test_delta_macros", "METH_NOARGS", """ PyObject* obj; PyDateTime_Delta* delta; PyDateTime_IMPORT; if (!PyDateTimeAPI) { PyErr_SetString(PyExc_RuntimeError, "No PyDateTimeAPI"); return NULL; } obj = PyDelta_FromDSU(6, 6, 6); delta = (PyDateTime_Delta*)obj; #if defined(PYPY_VERSION) || PY_VERSION_HEX >= 0x03030000 // These macros are only defined in CPython 3.x and PyPy. // See: http://bugs.python.org/issue13727 PyDateTime_DELTA_GET_DAYS(obj); PyDateTime_DELTA_GET_DAYS(delta); PyDateTime_DELTA_GET_SECONDS(obj); PyDateTime_DELTA_GET_SECONDS(delta); PyDateTime_DELTA_GET_MICROSECONDS(obj); PyDateTime_DELTA_GET_MICROSECONDS(delta); #endif return obj; """), ], prologue='#include "datetime.h"\n') import datetime assert module.test_date_macros() == datetime.date(2000, 6, 6) assert module.test_datetime_macros() == datetime.datetime( 2000, 6, 6, 6, 6, 6, 6) assert module.test_time_macros() == datetime.time(6, 6, 6, 6) assert module.test_delta_macros() == datetime.timedelta(6, 6, 6) try: test_macros() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestDatetime.test_tzinfo __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee409050>, 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_tzinfo'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tzinfo'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_tzinfo'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tzinfo'>} 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_tzinfo'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_tzinfo'>} 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_tzinfo'>, '__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 0x7ff8ee4d4af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_tzinfo'>, '__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 0x7ff8ee61a280> 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 0x7ff8ee61a280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_tzinfo'>, '__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_tzinfo'>, '__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 0x7ff8ee61a190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_tzinfo'>, '__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 0x7ff8ee61a1e0> 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 0x7ff8ee61a1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_tzinfo'>, '__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_tzinfo'>, '__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_tzinfo'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_tzinfo'> 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_tzinfo at 0x7ff8ef28d050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee412c90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee412f10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_tzinfo(): module = self.import_extension('foo', [ ("time_with_tzinfo", "METH_O", """ PyDateTime_IMPORT; return PyDateTimeAPI->Time_FromTime( 6, 6, 6, 6, args, PyDateTimeAPI->TimeType); """), ("datetime_with_tzinfo", "METH_O", """ PyObject * obj; int tzrefcnt = args->ob_refcnt; PyDateTime_IMPORT; obj = PyDateTimeAPI->DateTime_FromDateAndTime( 2000, 6, 6, 6, 6, 6, 6, args, PyDateTimeAPI->DateTimeType); if (!((PyDateTime_DateTime*)obj)->hastzinfo) { Py_DECREF(obj); PyErr_SetString(PyExc_ValueError, "missing tzinfo"); return NULL; } if (((PyDateTime_DateTime*)obj)->tzinfo->ob_refcnt <= tzrefcnt) { Py_DECREF(obj); PyErr_SetString(PyExc_ValueError, "tzinfo refcnt not incremented"); return NULL; } return obj; """), ], prologue='#include "datetime.h"\n') from datetime import tzinfo, datetime, timedelta, time # copied from datetime documentation class GMT1(tzinfo): def __del__(self): print('deleting GMT1') def utcoffset(self, dt): return timedelta(hours=1) + self.dst(dt) def dst(self, dt): return timedelta(0) def tzname(self,dt): return "GMT +1" gmt1 = GMT1() dt1 = module.time_with_tzinfo(gmt1) assert dt1 == time(6, 6, 6, 6, gmt1) assert '+01' in str(dt1) dt_tz = module.datetime_with_tzinfo(gmt1) assert dt_tz == datetime(2000, 6, 6, 6, 6, 6, 6, gmt1) try: test_tzinfo() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestDatetime.test_checks __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee6216d0>, 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_checks'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_checks'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_checks'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_checks'>} 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_checks'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_checks'>} 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_checks'>, '__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 0x7ff8ee4d41e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_checks'>, '__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 0x7ff8ee4d4690> 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 0x7ff8ee4d4690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_checks'>, '__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_checks'>, '__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 0x7ff8ee4d44b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_checks'>, '__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 0x7ff8ee4d4870> 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 0x7ff8ee4d4870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_checks'>, '__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_checks'>, '__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_checks'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_checks'> 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_checks at 0x7ff8ef28d0d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee4cfbd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4cf7d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_checks(): module = self.import_extension('foo', [ ("checks", "METH_O", """ PyDateTime_IMPORT; return PyTuple_Pack(10, PyBool_FromLong(PyDateTime_Check(args)), PyBool_FromLong(PyDateTime_CheckExact(args)), PyBool_FromLong(PyDate_Check(args)), PyBool_FromLong(PyDate_CheckExact(args)), PyBool_FromLong(PyTime_Check(args)), PyBool_FromLong(PyTime_CheckExact(args)), PyBool_FromLong(PyDelta_Check(args)), PyBool_FromLong(PyDelta_CheckExact(args)), PyBool_FromLong(PyTZInfo_Check(args)), PyBool_FromLong(PyTZInfo_CheckExact(args)) ); """), ], prologue='#include "datetime.h"\n') from datetime import tzinfo, datetime, timedelta, time, date o = date(1, 1, 1) assert module.checks(o) == (False,) * 2 + (True,) * 2 + (False,) * 6 o = time(1, 1, 1) assert module.checks(o) == (False,) * 4 + (True,) * 2 + (False,) * 4 o = timedelta(1, 1, 1) assert module.checks(o) == (False,) * 6 + (True,) * 2 + (False,) * 2 o = datetime(1, 1, 1) assert module.checks(o) == (True,) * 3 + (False,) * 7 # isinstance(datetime, date) o = tzinfo() assert module.checks(o) == (False,) * 8 + (True,) * 2 try: test_checks() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestDatetime.test_misc ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee621cd0>, 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_misc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_misc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_misc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_misc'>} 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_misc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_misc'>} 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_misc'>, '__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 0x7ff8ee39f960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_misc'>, '__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 0x7ff8ee39f9b0> 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 0x7ff8ee39f9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_misc'>, '__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_misc'>, '__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 0x7ff8ee39faa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_misc'>, '__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 0x7ff8ee39fb40> 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 0x7ff8ee39fb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_misc'>, '__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_misc'>, '__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_misc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_misc'> 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_misc at 0x7ff8ef28d150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDatetime.w_compile_module of <pypy.module.cpyext.test.test_datetime.AppTestDat...tDatetime.w_import_extension of <pypy.module.cpyext.test.test_datetime.AppTestDatetime object at 0x7ff8ee43a250>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee43a610> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_misc(): # Taken from the cython time_pxd.pyx test_time() test module = self.import_extension('foo', [ ("getsystemclock", "METH_NOARGS", """ PyDateTime_IMPORT; _PyTime_t tic = _PyTime_GetSystemClock(); double r = _PyTime_AsSecondsDouble(tic); return PyFloat_FromDouble(r); """), ("get_qualname", "METH_NOARGS", """ return PyType_GetQualName(PyDateTimeAPI->DateType); """), ], prologue='#include "datetime.h"\n') import time # warm up the time.time function for _ in range(2000): tic1 = time.time() tic2 = module.getsystemclock() tic3 = time.time() assert tic1 <= tic2, "%s, %s" % (tic1, tic2) assert tic2 <= tic3, "%s, %s" % (tic2, tic3) assert module.get_qualname() == "date" try: test_misc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestDictObject.test_dictproxytype _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee484350>, 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_dictproxytype'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dictproxytype'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_dictproxytype'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dictproxytype'>} 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_dictproxytype'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_dictproxytype'>} 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_dictproxytype'>, '__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 0x7ff8ee421550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tproxytype'>, '__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 0x7ff8ee4217d0> 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 0x7ff8ee4217d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tproxytype'>, '__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_dictproxytype'>, '__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 0x7ff8ee421500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tproxytype'>, '__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 0x7ff8ee421280> 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 0x7ff8ee421280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tproxytype'>, '__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_dictproxytype'>, '__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_dictproxytype'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_dictproxytype'> 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_dictproxytype at 0x7ff8ef2a71d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee41f9d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee41ff90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_dictproxytype(): module = self.import_extension('foo', [ ("dict_proxy", "METH_VARARGS", """ PyObject * dict; PyObject * proxydict; int i; if (!PyArg_ParseTuple(args, "O", &dict)) return NULL; proxydict = PyDictProxy_New(dict); #ifdef PYPY_VERSION // PyDictProxy_Check[Exact] are PyPy-specific. if (!PyDictProxy_Check(proxydict)) { Py_DECREF(proxydict); PyErr_SetNone(PyExc_ValueError); return NULL; } if (!PyDictProxy_CheckExact(proxydict)) { Py_DECREF(proxydict); PyErr_SetNone(PyExc_ValueError); return NULL; } #endif // PYPY_VERSION i = PyObject_Size(proxydict); Py_DECREF(proxydict); return PyLong_FromLong(i); """), ]) assert module.dict_proxy({'a': 1, 'b': 2}) == 2 try: test_dictproxytype() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestDictObject.test_getitemwitherror ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee572250>, 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_getitemwitherror'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitemwitherror'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getitemwitherror'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitemwitherror'>} 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_getitemwitherror'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitemwitherror'>} 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_getitemwitherror'>, '__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 0x7ff8ee61aeb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mwitherror'>, '__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 0x7ff8ee61a1e0> 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 0x7ff8ee61a1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mwitherror'>, '__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_getitemwitherror'>, '__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 0x7ff8ee61a3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mwitherror'>, '__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 0x7ff8ee61a6e0> 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 0x7ff8ee61a6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mwitherror'>, '__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_getitemwitherror'>, '__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_getitemwitherror'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getitemwitherror'> 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_getitemwitherror at 0x7ff8ef2a7250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee388b10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee388210> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getitemwitherror(): module = self.import_extension('foo', [ ("dict_getitem", "METH_VARARGS", """ PyObject *d, *key, *result; if (!PyArg_ParseTuple(args, "OO", &d, &key)) { return NULL; } result = PyDict_GetItemWithError(d, key); if (result == NULL && !PyErr_Occurred()) Py_RETURN_NONE; Py_XINCREF(result); return result; """), ("dict_getitem_string", "METH_VARARGS", """ PyObject *d, *result; char * key; if (!PyArg_ParseTuple(args, "Os", &d, &key)) { return NULL; } result = _PyDict_GetItemStringWithError(d, key); if (result == NULL && !PyErr_Occurred()) Py_RETURN_NONE; Py_XINCREF(result); return result; """)]) d = {'foo': 'bar'} assert module.dict_getitem(d, 'foo') == 'bar' assert module.dict_getitem_string(d, 'foo') == 'bar' assert module.dict_getitem(d, 'missing') is None assert module.dict_getitem_string(d, 'missing') is None with raises(TypeError): module.dict_getitem(d, []) with raises(TypeError): module.dict_getitem_string(d, []) try: test_getitemwitherror() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestDictObject.test_setdefault _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee51b2d0>, 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_setdefault'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_setdefault'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_setdefault'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_setdefault'>} 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_setdefault'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_setdefault'>} 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_setdefault'>, '__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 0x7ff8ee344460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...setdefault'>, '__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 0x7ff8ee344640> 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 0x7ff8ee344640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...setdefault'>, '__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_setdefault'>, '__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 0x7ff8ee344730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...setdefault'>, '__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 0x7ff8ee3447d0> 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 0x7ff8ee3447d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...setdefault'>, '__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_setdefault'>, '__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_setdefault'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_setdefault'> 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_setdefault at 0x7ff8ef2a72d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee3bda90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3bd2d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_setdefault(): module = self.import_extension('foo', [ ("setdefault", "METH_VARARGS", ''' PyObject *d, *key, *defaultobj, *val; if (!PyArg_ParseTuple(args, "OOO", &d, &key, &defaultobj)) return NULL; val = PyDict_SetDefault(d, key, defaultobj); Py_XINCREF(val); return val; ''')]) class Dict(dict): def setdefault(self, key, default): return 42 d = Dict() assert module.setdefault(d, 'x', 1) == 1 assert d['x'] == 1 try: test_setdefault() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestDictObject.test_update _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee514d50>, 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_update'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_update'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_update'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_update'>} 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_update'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_update'>} 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_update'>, '__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 0x7ff8ee39f8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_update'>, '__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 0x7ff8ee344050> 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 0x7ff8ee344050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_update'>, '__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_update'>, '__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 0x7ff8ee3b8370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_update'>, '__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 0x7ff8ee3b82d0> 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 0x7ff8ee3b82d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_update'>, '__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_update'>, '__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_update'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_update'> 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_update at 0x7ff8ef2a7350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee3b0d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3b0890> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_update(): module = self.import_extension('foo', [ ("update", "METH_VARARGS", ''' if (PyDict_Update(PyTuple_GetItem(args, 0), PyTuple_GetItem(args, 1))) return NULL; Py_RETURN_NONE; ''')]) d = {"a": 1} module.update(d, {"c": 2}) assert d == dict(a=1, c=2) d = {"a": 1} raises(AttributeError, module.update, d, [("c", 2)]) try: test_update() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestDictObject.test_iter __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee50a2d0>, 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_iter'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iter'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_iter'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iter'>} 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_iter'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iter'>} 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_iter'>, '__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 0x7ff8ee349280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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 0x7ff8ee3495f0> 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 0x7ff8ee3495f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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_iter'>, '__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 0x7ff8ee3496e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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 0x7ff8ee349780> 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 0x7ff8ee349780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_iter'>, '__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_iter'>, '__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_iter'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_iter'> 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_iter at 0x7ff8ef2a73d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee3b3790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3b3e10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_iter(): module = self.import_extension('foo', [ ("copy", "METH_O", ''' Py_ssize_t pos = 0; PyObject *key, *value; PyObject* copy = PyDict_New(); while (PyDict_Next(args, &pos, &key, &value)) { if (PyDict_SetItem(copy, key, value) < 0) { Py_DecRef(copy); return NULL; } } return copy; ''')]) d = {1: 'xyz', 3: 'abcd'} copy = module.copy(d) assert len(copy) == len(d) assert copy == d try: test_iter() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestDictObject.test_iterkeys ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee514d50>, 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_iterkeys'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iterkeys'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_iterkeys'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iterkeys'>} 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_iterkeys'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iterkeys'>} 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_iterkeys'>, '__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 0x7ff8ee4e9230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_iterkeys'>, '__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 0x7ff8ee4e9af0> 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 0x7ff8ee4e9af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_iterkeys'>, '__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_iterkeys'>, '__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 0x7ff8ee4e91e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_iterkeys'>, '__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 0x7ff8ee4e92d0> 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 0x7ff8ee4e92d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_iterkeys'>, '__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_iterkeys'>, '__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_iterkeys'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_iterkeys'> 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_iterkeys at 0x7ff8ef2a7450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee3b4210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3b4650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_iterkeys(): module = self.import_extension('foo', [ ("keys_and_values", "METH_O", ''' Py_ssize_t pos = 0; PyObject *key, *value, *values; PyObject* keys = PyList_New(0); while (PyDict_Next(args, &pos, &key, NULL)) { if (PyList_Append(keys, key) < 0) { Py_DecRef(keys); return NULL; } } pos = 0; values = PyList_New(0); while (PyDict_Next(args, &pos, NULL, &value)) { if (PyList_Append(values, value) < 0) { Py_DecRef(keys); Py_DecRef(values); return NULL; } } return Py_BuildValue("(NN)", keys, values); ''')]) d = {1: 'xyz', 3: 'abcd'} assert module.keys_and_values(d) == (list(d.keys()), list(d.values())) try: test_iterkeys() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestDictObject.test_typedict2 _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee6216d0>, 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_typedict2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typedict2'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_typedict2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typedict2'>} 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_typedict2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typedict2'>} 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_typedict2'>, '__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 0x7ff8ee3507d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typedict2'>, '__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 0x7ff8ee350a00> 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 0x7ff8ee350a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typedict2'>, '__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_typedict2'>, '__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 0x7ff8ee350a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typedict2'>, '__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 0x7ff8ee350b40> 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 0x7ff8ee350b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typedict2'>, '__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_typedict2'>, '__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_typedict2'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_typedict2'> 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_typedict2 at 0x7ff8ef2a74d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee3b4410>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3b3ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_typedict2(): module = self.import_extension('foo', [ ("get_type_dict", "METH_O", ''' PyObject* value = args->ob_type->tp_dict; if (value == NULL) value = Py_None; Py_INCREF(value); return value; '''), ]) d = module.get_type_dict(1) assert d['real'].__get__(1, 1) == 1 try: test_typedict2() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestDictObject.test_advanced ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee5725d0>, 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_advanced'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_advanced'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_advanced'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_advanced'>} 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_advanced'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_advanced'>} 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_advanced'>, '__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 0x7ff8ee4e9af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_advanced'>, '__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 0x7ff8ee4e90a0> 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 0x7ff8ee4e90a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_advanced'>, '__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_advanced'>, '__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 0x7ff8ee4e9820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_advanced'>, '__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 0x7ff8ee4e95a0> 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 0x7ff8ee4e95a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_advanced'>, '__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_advanced'>, '__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_advanced'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_advanced'> 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_advanced at 0x7ff8ef2a7550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee345c90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee345a10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_advanced(): module = self.import_extension('foo', [ ("dict_len", "METH_O", ''' int ret = args->ob_type->tp_as_mapping->mp_length(args); return PyLong_FromLong(ret); '''), ("dict_setitem", "METH_VARARGS", ''' int ret; PyObject * dict = PyTuple_GetItem(args, 0); if (PyTuple_Size(args) < 3 || !dict || !dict->ob_type->tp_as_mapping || !dict->ob_type->tp_as_mapping->mp_ass_subscript) return PyLong_FromLong(-1); ret = dict->ob_type->tp_as_mapping->mp_ass_subscript( dict, PyTuple_GetItem(args, 1), PyTuple_GetItem(args, 2)); return PyLong_FromLong(ret); '''), ("dict_delitem", "METH_VARARGS", ''' int ret; PyObject * dict = PyTuple_GetItem(args, 0); if (PyTuple_Size(args) < 2 || !dict || !dict->ob_type->tp_as_mapping || !dict->ob_type->tp_as_mapping->mp_ass_subscript) return PyLong_FromLong(-1); ret = dict->ob_type->tp_as_mapping->mp_ass_subscript( dict, PyTuple_GetItem(args, 1), NULL); return PyLong_FromLong(ret); '''), ("dict_next", "METH_VARARGS", ''' PyObject *key, *value; PyObject *arg = NULL; Py_ssize_t pos = 0; int ret = 0; if ((PyArg_ParseTuple(args, "|O", &arg))) { if (arg && PyDict_Check(arg)) { while (PyDict_Next(arg, &pos, &key, &value)) ret ++; /* test no crash if pos is not reset to 0*/ while (PyDict_Next(arg, &pos, &key, &value)) ret ++; } } return PyLong_FromLong(ret); '''), ("exhaust_pos", "METH_O", """ PyObject *key, *val; Py_ssize_t pos = 0; while (PyDict_Next(args, &pos, &key, &val)) { } return PyLong_FromLong(pos); """), ]) d = {'a': 1, 'b':2} assert module.dict_len(d) == 2 assert module.dict_setitem(d, 'a', 'c') == 0 assert d['a'] == 'c' assert module.dict_delitem(d, 'a') == 0 r = module.dict_next({'a': 1, 'b': 2}) assert r == 2 assert module.exhaust_pos({'a': 1}) == 1 try: test_advanced() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestDictObject.test_subclassing ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee370c50>, 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_subclassing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclassing'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_subclassing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclassing'>} 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_subclassing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_subclassing'>} 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_subclassing'>, '__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 0x7ff8ee350370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ubclassing'>, '__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 0x7ff8ee350190> 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 0x7ff8ee350190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ubclassing'>, '__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_subclassing'>, '__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 0x7ff8ee3509b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ubclassing'>, '__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 0x7ff8ee3502d0> 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 0x7ff8ee3502d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ubclassing'>, '__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_subclassing'>, '__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_subclassing'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_subclassing'> 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_subclassing at 0x7ff8ef2a75d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee450b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee450d90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_subclassing(): module = self.import_extension('foo', [ ("dict_setitem", "METH_VARARGS", """ PyObject *d, *key, *value; if (!PyArg_ParseTuple(args, "OOO", &d, &key, &value)) { return NULL; } if (PyDict_SetItem(d, key, value) < 0) { return NULL; } Py_RETURN_NONE; """), ("dict_delitem", "METH_VARARGS", """ PyObject *d, *key; if (!PyArg_ParseTuple(args, "OO", &d, &key)) { return NULL; } if (PyDict_DelItem(d, key) < 0) { return NULL; } Py_RETURN_NONE; """), ("dict_getitem", "METH_VARARGS", """ PyObject *d, *key, *result; if (!PyArg_ParseTuple(args, "OO", &d, &key)) { return NULL; } result = PyDict_GetItem(d, key); Py_XINCREF(result); return result; """), ]) class mydict(dict): def __setitem__(self, key, value): dict.__setitem__(self, key, 42) def __delitem__(self, key): dict.__setitem__(self, key, None) d = {} module.dict_setitem(d, 1, 2) assert d[1] == 2 d = mydict() d[1] = 2 assert d[1] == 42 module.dict_setitem(d, 2, 3) assert d[2] == 3 del d[2] assert d[2] is None module.dict_delitem(d, 2) assert 2 not in d class mydict2(dict): def __getitem__(self, key): return 42 d = mydict2() d[1] = 2 assert d[1] == 42 assert module.dict_getitem(d, 1) == 2 try: test_subclassing() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestDictObject.test_getitem_error _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee40bf50>, 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_getitem_error'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_error'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getitem_error'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_error'>} 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_getitem_error'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_error'>} 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_getitem_error'>, '__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 0x7ff8ee468550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_error'>, '__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 0x7ff8ee39f730> 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 0x7ff8ee39f730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_error'>, '__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_getitem_error'>, '__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 0x7ff8ee39f1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_error'>, '__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 0x7ff8ee4085f0> 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 0x7ff8ee4085f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_error'>, '__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_getitem_error'>, '__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_getitem_error'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getitem_error'> 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_getitem_error at 0x7ff8ef2a7650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee4504d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee412810> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getitem_error(): module = self.import_extension('foo', [ ("dict_getitem", "METH_VARARGS", """ PyObject *d, *key, *result; if (!PyArg_ParseTuple(args, "OO", &d, &key)) { return NULL; } result = PyDict_GetItem(d, key); if (!result) Py_RETURN_NONE; Py_XINCREF(result); return result; """), ]) assert module.dict_getitem(42, 43) is None assert module.dict_getitem({}, []) is None try: test_getitem_error() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestDictObject.test_contains ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee413050>, 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_contains'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_contains'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_contains'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_contains'>} 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_contains'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_contains'>} 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_contains'>, '__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 0x7ff8ee3e5460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_contains'>, '__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 0x7ff8ee3e5550> 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 0x7ff8ee3e5550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_contains'>, '__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_contains'>, '__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 0x7ff8ee3e55f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_contains'>, '__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 0x7ff8ee3e56e0> 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 0x7ff8ee3e56e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_contains'>, '__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_contains'>, '__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_contains'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_contains'> 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_contains at 0x7ff8ef2a76d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestDictObject.w_compile_module of <pypy.module.cpyext.test.test_dictobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_dictobject.AppTestDictObject object at 0x7ff8ee37c310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee37ca50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_contains(): module = self.import_extension('foo', [ ("contains", "METH_VARARGS", """ PyObject *d, *key; if (!PyArg_ParseTuple(args, "OO", &d, &key)) { return NULL; } int ret = PyDict_Contains(d, key); if (ret < 0) return NULL; return PyLong_FromLong(ret); """), ]) class Unhashable(): __hash__ = None raises(TypeError, module.contains, {}, Unhashable()) class C(dict): def __contains__(self, key): return dict.__contains__(self, key) ret = module.contains(C(), 1) assert ret == 0 try: test_contains() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestCall.test_CallFunction _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee572550>, 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_CallFunction'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunction'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_CallFunction'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunction'>} 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_CallFunction'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunction'>} 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_CallFunction'>, '__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 0x7ff8ee31b910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llFunction'>, '__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 0x7ff8ee31ba00> 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 0x7ff8ee31ba00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llFunction'>, '__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_CallFunction'>, '__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 0x7ff8ee31baa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llFunction'>, '__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 0x7ff8ee31bb90> 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 0x7ff8ee31bb90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llFunction'>, '__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_CallFunction'>, '__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_CallFunction'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_CallFunction'> 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_CallFunction at 0x7ff8ef2c01d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee358890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee375190> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_CallFunction(): module = self.import_extension('foo', [ ("call_func", "METH_VARARGS", """ return PyObject_CallFunction(PyTuple_GetItem(args, 0), "siiiiO", "text", 42, -41, 40, -39, Py_None); """), ("call_method", "METH_VARARGS", """ return PyObject_CallMethod(PyTuple_GetItem(args, 0), "count", "s", "t"); """), ]) def f(*args): return args assert module.call_func(f) == ("text", 42, -41, 40, -39, None) assert module.call_method("text") == 2 try: test_CallFunction() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestCall.test_CallFunction_PY_SSIZE_T_CLEAN ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee621cd0>, 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_CallFunction_PY_SSIZE_T_CLEAN'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunction_PY_SSIZE_T_CLEAN'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_CallFunction_PY_SSIZE_T_CLEAN'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunction_PY_SSIZE_T_CLEAN'>} 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_CallFunction_PY_SSIZE_T_CLEAN'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunction_PY_SSIZE_T_CLEAN'>} 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_CallFunction_PY_SSIZE_T_CLEAN'>, '__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 0x7ff8ee4e95f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ZE_T_CLEAN'>, '__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 0x7ff8ee3515a0> 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 0x7ff8ee3515a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ZE_T_CLEAN'>, '__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_CallFunction_PY_SSIZE_T_CLEAN'>, '__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 0x7ff8ee35e6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ZE_T_CLEAN'>, '__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 0x7ff8ee35ee60> 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 0x7ff8ee35ee60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ZE_T_CLEAN'>, '__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_CallFunction_PY_SSIZE_T_CLEAN'>, '__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_CallFunction_PY_SSIZE_T_CLEAN'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_CallFunction_PY_SSIZE_T_CLEAN'> 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_CallFunction_PY_SSIZE_T_CLEAN at 0x7ff8ef2c0250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee450210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee450290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_CallFunction_PY_SSIZE_T_CLEAN(): module = self.import_extension('foo', [ ("call_func", "METH_VARARGS", """ return PyObject_CallFunction(PyTuple_GetItem(args, 0), "s#s#", "text", (Py_ssize_t)3, "othertext", (Py_ssize_t)6); """), ("call_method", "METH_VARARGS", """ return PyObject_CallMethod(PyTuple_GetItem(args, 0), "find", "s#", "substring", (Py_ssize_t)6); """), ], PY_SSIZE_T_CLEAN=True) def f(*args): return args assert module.call_func(f) == ("tex", "othert") assert module.call_method("<<subst>>") == -1 assert module.call_method("<<substr>>") == 2 try: test_CallFunction_PY_SSIZE_T_CLEAN() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestCall.test_CallFunctionObjArgs _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee572550>, 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_CallFunctionObjArgs'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunctionObjArgs'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_CallFunctionObjArgs'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunctionObjArgs'>} 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_CallFunctionObjArgs'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CallFunctionObjArgs'>} 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_CallFunctionObjArgs'>, '__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 0x7ff8ee320a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ionObjArgs'>, '__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 0x7ff8ee320b40> 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 0x7ff8ee320b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ionObjArgs'>, '__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_CallFunctionObjArgs'>, '__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 0x7ff8ee320be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ionObjArgs'>, '__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 0x7ff8ee320cd0> 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 0x7ff8ee320cd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ionObjArgs'>, '__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_CallFunctionObjArgs'>, '__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_CallFunctionObjArgs'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_CallFunctionObjArgs'> 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_CallFunctionObjArgs at 0x7ff8ef2c02d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee345050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee345d10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_CallFunctionObjArgs(): module = self.import_extension('foo', [ ("call_func", "METH_VARARGS", """ PyObject *t = PyUnicode_FromString("t"); PyObject *res = PyObject_CallFunctionObjArgs( PyTuple_GetItem(args, 0), Py_None, NULL); Py_DECREF(t); return res; """), ("call_method", "METH_VARARGS", """ PyObject *t = PyUnicode_FromString("t"); PyObject *count = PyUnicode_FromString("count"); PyObject *res = PyObject_CallMethodObjArgs( PyTuple_GetItem(args, 0), count, t, NULL); Py_DECREF(t); Py_DECREF(count); return res; """), ("test_callnoarg", "METH_VARARGS", ''' PyObject *func = NULL; if (!PyArg_ParseTuple(args, "O", &func)) { return NULL; } return PyObject_CallNoArgs(func); '''), ("test_callonearg", "METH_VARARGS", ''' PyObject *func = NULL, *arg = NULL; if (!PyArg_ParseTuple(args, "OO", &func, &arg)) { return NULL; } return PyObject_CallOneArg(func, arg); '''), ("test_callmethod_noargs", "METH_VARARGS", ''' PyObject *func = NULL, *arg = NULL; if (!PyArg_ParseTuple(args, "OO", &func, &arg)) { return NULL; } return PyObject_CallMethodNoArgs(func, arg); '''), ("test_callmethod_onearg", "METH_VARARGS", ''' PyObject *func = NULL, *name = NULL, *arg = NULL; if (!PyArg_ParseTuple(args, "OOO", &func, &name, &arg)) { return NULL; } return PyObject_CallMethodOneArg(func, name, arg); '''), ]) def f(*args): return args class A(): def meth(self, *args): return args a = A() assert module.call_func(f) == (None,) assert module.call_method("text") == 2 module.test_callnoarg(f) == () module.test_callonearg(f, 4) == (4,) assert module.test_callmethod_noargs(a, "meth") == () assert module.test_callmethod_onearg(a, "meth", 4) == (4,) try: test_CallFunctionObjArgs() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestCall.test_CompileString_and_Exec ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee5bd3d0>, 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_CompileString_and_Exec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CompileString_and_Exec'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_CompileString_and_Exec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CompileString_and_Exec'>} 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_CompileString_and_Exec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_CompileString_and_Exec'>} 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_CompileString_and_Exec'>, '__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 0x7ff8ee312910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...g_and_Exec'>, '__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 0x7ff8ee312a00> 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 0x7ff8ee312a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...g_and_Exec'>, '__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_CompileString_and_Exec'>, '__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 0x7ff8ee312aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...g_and_Exec'>, '__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 0x7ff8ee312b90> 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 0x7ff8ee312b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...g_and_Exec'>, '__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_CompileString_and_Exec'>, '__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_CompileString_and_Exec'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_CompileString_and_Exec'> 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_CompileString_and_Exec at 0x7ff8ef2c0350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee450290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee361e90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_CompileString_and_Exec(): import sys module = self.import_extension('foo', [ ("compile_string", "METH_NOARGS", """ return Py_CompileString( "f = lambda x: x+5", "someFile", Py_file_input); """), ("exec_code", "METH_O", """ return PyImport_ExecCodeModule("cpyext_test_modname", args); """), ("exec_code_ex", "METH_O", """ return PyImport_ExecCodeModuleEx("cpyext_test_modname", args, "otherFile"); """), ]) code = module.compile_string() assert code.co_filename == "someFile" assert code.co_name == "<module>" mod = module.exec_code(code) assert mod.__name__ == "cpyext_test_modname" assert mod.__file__ == "someFile" print(dir(mod)) print(mod.__dict__) assert mod.f(42) == 47 mod = module.exec_code_ex(code) assert mod.__name__ == "cpyext_test_modname" assert mod.__file__ == "otherFile" print(dir(mod)) print(mod.__dict__) assert mod.f(42) == 47 # Clean-up del sys.modules['cpyext_test_modname'] try: test_CompileString_and_Exec() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestCall.test_merge_compiler_flags _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3db0d0>, 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_merge_compiler_flags'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_merge_compiler_flags'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_merge_compiler_flags'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_merge_compiler_flags'>} 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_merge_compiler_flags'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_merge_compiler_flags'>} 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_merge_compiler_flags'>, '__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 0x7ff8ee33d500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...iler_flags'>, '__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 0x7ff8ee33d5f0> 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 0x7ff8ee33d5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...iler_flags'>, '__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_merge_compiler_flags'>, '__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 0x7ff8ee33d690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...iler_flags'>, '__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 0x7ff8ee33d780> 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 0x7ff8ee33d780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...iler_flags'>, '__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_merge_compiler_flags'>, '__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_merge_compiler_flags'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_merge_compiler_flags'> 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_merge_compiler_flags at 0x7ff8ef2c03d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee3d5a90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3d5e50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_merge_compiler_flags(): import sys module = self.import_extension('foo', [ ("get_flags", "METH_NOARGS", """ PyCompilerFlags flags; int result; flags.cf_flags = 0; result = PyEval_MergeCompilerFlags(&flags); return Py_BuildValue("ii", result, flags.cf_flags); """), ]) assert module.get_flags() == (0, 0) ns = {'module': module} if not hasattr(sys, 'pypy_version_info'): # no barry_as_FLUFL on pypy exec("""from __future__ import barry_as_FLUFL \nif 1: def nested_flags(): return module.get_flags()""", ns) assert ns['nested_flags']() == (1, 0x40000) # the division future should have no effect on Python 3 exec("""from __future__ import division \nif 1: def nested_flags(): return module.get_flags()""", ns) assert ns['nested_flags']() == (0, 0) try: test_merge_compiler_flags() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestCall.test_recursive_function ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee480b50>, 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_recursive_function'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_recursive_function'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_recursive_function'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_recursive_function'>} 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_recursive_function'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_recursive_function'>} 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_recursive_function'>, '__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 0x7ff8ee340a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_function'>, '__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 0x7ff8ee340b90> 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 0x7ff8ee340b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_function'>, '__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_recursive_function'>, '__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 0x7ff8ee340b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_function'>, '__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 0x7ff8ee340c30> 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 0x7ff8ee340c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_function'>, '__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_recursive_function'>, '__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_recursive_function'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_recursive_function'> 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_recursive_function at 0x7ff8ef2c0450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee3ec0d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3ec790> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_recursive_function(): module = self.import_extension('foo', [ ("call_recursive", "METH_NOARGS", """ int oldlimit; int recurse(void); res = 0; oldlimit = Py_GetRecursionLimit(); Py_SetRecursionLimit(oldlimit/100); res = recurse(); Py_SetRecursionLimit(oldlimit); if (PyErr_Occurred()) return NULL; return PyLong_FromLong(res); """),], prologue= ''' int res; int recurse(void) { if (Py_EnterRecursiveCall(" while calling recurse")) { return -1; } res ++; return recurse(); }; ''' ) excinfo = raises(RecursionError, module.call_recursive) assert 'while calling recurse' in str(excinfo.value) try: test_recursive_function() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestCall.test_build_class _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3db0d0>, 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_build_class'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_build_class'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_build_class'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_build_class'>} 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_build_class'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_build_class'>} 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_build_class'>, '__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 0x7ff8ee2d7460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uild_class'>, '__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 0x7ff8ee2d7550> 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 0x7ff8ee2d7550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uild_class'>, '__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_build_class'>, '__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 0x7ff8ee2d75f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uild_class'>, '__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 0x7ff8ee2d76e0> 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 0x7ff8ee2d76e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uild_class'>, '__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_build_class'>, '__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_build_class'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_build_class'> 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_ = 'test_build_class(self): \n # make sure PyObject_Call generates a proper PyTypeObject,\n # along the way veri... return s\n \n assert run_async(list1()) == ([], [0, 1, 2])\n assert run_async(list2()) == ([], [0, 1, 2])' usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee361d10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3b4590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_build_class(): # make sure PyObject_Call generates a proper PyTypeObject, # along the way verify that userslot has iter and next module = self.import_extension('foo', [ ("object_call", "METH_O", ''' return PyObject_Call((PyObject*)&PyType_Type, args, NULL); '''), ('iter', "METH_O", ''' if (NULL == args->ob_type->tp_iter) { PyErr_SetString(PyExc_TypeError, "NULL tp_iter"); return NULL; } return args->ob_type->tp_iter(args); '''), ('next', "METH_O", ''' if (NULL == args->ob_type->tp_iternext) { PyErr_SetString(PyExc_TypeError, "NULL tp_iternext"); return NULL; } return args->ob_type->tp_iternext(args); '''), ('await_', "METH_O", ''' if (NULL == args->ob_type->tp_as_async->am_await) { PyErr_SetString(PyExc_TypeError, "NULL am_await"); return NULL; } return args->ob_type->tp_as_async->am_await(args); '''), ('aiter', "METH_O", ''' if (NULL == args->ob_type->tp_as_async->am_aiter) { PyErr_SetString(PyExc_TypeError, "NULL am_aiter"); return NULL; } return args->ob_type->tp_as_async->am_aiter(args); '''), ('anext', "METH_O", ''' if (NULL == args->ob_type->tp_as_async->am_anext) { PyErr_SetString(PyExc_TypeError, "NULL am_anext"); return NULL; } return args->ob_type->tp_as_async->am_anext(args); '''), ]) def __init__(self, N): self.N = N self.i = 0 def __iter__(self): return self def __next__(self): if self.i < self.N: i = self.i self.i += 1 return i raise StopIteration d = {'__init__': __init__, '__iter__': __iter__, 'next': __next__, '__next__': __next__} C = module.object_call(('Iterable', (object,), d)) c = C(5) i = module.iter(c) out = [] try: while 1: out.append(module.next(i)) except StopIteration: pass assert out == [0, 1, 2, 3, 4] def run_async(coro): buffer = [] result = None while True: try: buffer.append(coro.send(None)) except StopIteration as ex: result = ex.value break return buffer, result def __await__(self): yield 42 return 100 Awaitable = module.object_call(( 'Awaitable', (object,), {'__await__': __await__})) async def wrapper(): return await Awaitable() assert run_async(module.await_(Awaitable())) == ([42], 100) assert run_async(wrapper()) == ([42], 100) def __aiter__(self): return self async def __anext__(self): if self.i < self.N: res = self.i self.i += 1 return res raise StopAsyncIteration AIter = module.object_call(('AIter', (object,), {'__init__': __init__, '__aiter__': __aiter__, '__anext__': __anext__})) async def list1(): s = [] async for i in AIter(3): s.append(i) return s async def list2(): s = [] ait = module.aiter(AIter(3)) try: while True: s.append(await module.anext(ait)) except StopAsyncIteration: return s assert run_async(list1()) == ([], [0, 1, 2]) assert run_async(list2()) == ([], [0, 1, 2]) try: test_build_class() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestCall.test_getframe ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3dbc50>, 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_getframe'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getframe'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getframe'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getframe'>} 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_getframe'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getframe'>} 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_getframe'>, '__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 0x7ff8ee2f1410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getframe'>, '__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 0x7ff8ee2f1500> 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 0x7ff8ee2f1500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getframe'>, '__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_getframe'>, '__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 0x7ff8ee2f1460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getframe'>, '__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 0x7ff8ee2f15a0> 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 0x7ff8ee2f15a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getframe'>, '__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_getframe'>, '__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_getframe'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getframe'> 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_getframe at 0x7ff8ef2c0550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee323610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee35d550> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getframe(): import sys module = self.import_extension('foo', [ ("getframe1", "METH_NOARGS", """ PyFrameObject *x = PyEval_GetFrame(); Py_INCREF(x); return (PyObject *)x; """),], prologue="#include <frameobject.h>\n") res = module.getframe1() assert res is sys._getframe(0) try: test_getframe() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestCall.test_getbuiltins _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3db0d0>, 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_getbuiltins'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getbuiltins'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getbuiltins'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getbuiltins'>} 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_getbuiltins'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getbuiltins'>} 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_getbuiltins'>, '__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 0x7ff8ee2fca00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etbuiltins'>, '__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 0x7ff8ee2fcaf0> 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 0x7ff8ee2fcaf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etbuiltins'>, '__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_getbuiltins'>, '__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 0x7ff8ee2fcb90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etbuiltins'>, '__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 0x7ff8ee2fcc80> 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 0x7ff8ee2fcc80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etbuiltins'>, '__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_getbuiltins'>, '__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_getbuiltins'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getbuiltins'> 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_getbuiltins at 0x7ff8ef2c05d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_eval.AppTestCall object...ethod AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_eval.AppTestCall object at 0x7ff8ee3d5f10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3d57d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getbuiltins(): module = self.import_extension('foo', [ ("getbuiltins", "METH_NOARGS", """ /* borrowed ref */ PyObject *ret = PyEval_GetBuiltins(); Py_INCREF(ret); return ret; """)]) builtins = module.getbuiltins() assert builtins is __builtins__.__dict__ def cpybuiltins(): return module.getbuiltins() d = dict(__builtins__ = {'sum': sum}, cpybuiltins=cpybuiltins) result = eval("cpybuiltins()", d, d) assert len(result) == len(builtins) try: test_getbuiltins() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestExceptions.test_OSError_aliases ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee4aa2d0>, 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_OSError_aliases'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_OSError_aliases'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_OSError_aliases'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_OSError_aliases'>} 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_OSError_aliases'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_OSError_aliases'>} 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_OSError_aliases'>, '__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 0x7ff8ee2f1eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...or_aliases'>, '__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 0x7ff8ee2f1dc0> 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 0x7ff8ee2f1dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...or_aliases'>, '__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_OSError_aliases'>, '__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 0x7ff8ee2f1c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...or_aliases'>, '__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 0x7ff8ee2f15a0> 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 0x7ff8ee2f15a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...or_aliases'>, '__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_OSError_aliases'>, '__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_OSError_aliases'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_OSError_aliases'> 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_OSError_aliases at 0x7ff8ef2d5650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestExceptions.w_compile_module of <pypy.module.cpyext.test.test_exception.AppTest...ptions.w_import_extension of <pypy.module.cpyext.test.test_exception.AppTestExceptions object at 0x7ff8ee3d5190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3d5f50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_OSError_aliases(): module = self.import_extension('foo', [ ("get_aliases", "METH_NOARGS", """ return PyTuple_Pack(2, PyExc_EnvironmentError, PyExc_IOError); """)]) assert module.get_aliases() == (OSError, OSError) try: test_OSError_aliases() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestExceptions.test_implicit_chaining ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee56e250>, 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_implicit_chaining'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_implicit_chaining'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_implicit_chaining'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_implicit_chaining'>} 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_implicit_chaining'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_implicit_chaining'>} 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_implicit_chaining'>, '__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 0x7ff8ee24b820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_chaining'>, '__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 0x7ff8ee24b910> 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 0x7ff8ee24b910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_chaining'>, '__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_implicit_chaining'>, '__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 0x7ff8ee24b9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_chaining'>, '__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 0x7ff8ee24baa0> 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 0x7ff8ee24baa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_chaining'>, '__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_implicit_chaining'>, '__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_implicit_chaining'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_implicit_chaining'> 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_implicit_chaining at 0x7ff8ef2d56d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestExceptions.w_compile_module of <pypy.module.cpyext.test.test_exception.AppTest...ptions.w_import_extension of <pypy.module.cpyext.test.test_exception.AppTestExceptions object at 0x7ff8ee3ece90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3ec550> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_implicit_chaining(): module = self.import_extension('foo', [ ("raise_exc", "METH_NOARGS", """ PyObject *ev, *et, *tb; PyObject *ev0, *et0, *tb0; PyErr_GetExcInfo(&ev0, &et0, &tb0); PyErr_SetString(PyExc_ValueError, "foo"); // simplified copy of __Pyx_GetException PyErr_Fetch(&et, &ev, &tb); PyErr_NormalizeException(&et, &ev, &tb); if (tb) PyException_SetTraceback(ev, tb); PyErr_SetExcInfo(et, ev, tb); PyErr_SetString(PyExc_TypeError, "bar"); PyErr_SetExcInfo(ev0, et0, tb0); return NULL; """)]) excinfo = raises(TypeError, module.raise_exc) assert excinfo.value.__context__ try: test_implicit_chaining() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestFileObject.test_defaultencoding ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee477850>, 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_defaultencoding'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_defaultencoding'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_defaultencoding'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_defaultencoding'>} 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_defaultencoding'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_defaultencoding'>} 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_defaultencoding'>, '__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 0x7ff8ee3409b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ltencoding'>, '__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 0x7ff8ee340500> 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 0x7ff8ee340500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ltencoding'>, '__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_defaultencoding'>, '__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 0x7ff8ee340050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ltencoding'>, '__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 0x7ff8ee2fc8c0> 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 0x7ff8ee2fc8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ltencoding'>, '__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_defaultencoding'>, '__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_defaultencoding'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_defaultencoding'> 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_defaultencoding at 0x7ff8ef2d5950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFileObject.w_compile_module of <pypy.module.cpyext.test.test_fileobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_fileobject.AppTestFileObject object at 0x7ff8ee2c2d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2c21d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_defaultencoding(): import sys module = self.import_extension('foo', [ ("defenc", "METH_NOARGS", """ return PyUnicode_FromString(Py_FileSystemDefaultEncoding); """), ]) assert module.defenc() == sys.getfilesystemencoding() try: test_defaultencoding() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestFloatObject.test_fromstring ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee472c50>, 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_fromstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromstring'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromstring'>} 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_fromstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromstring'>} 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_fromstring'>, '__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 0x7ff8ee38d9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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 0x7ff8ee38d960> 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 0x7ff8ee38d960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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_fromstring'>, '__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 0x7ff8ee38dcd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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 0x7ff8ee38d690> 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 0x7ff8ee38d690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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_fromstring'>, '__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_fromstring'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromstring'> 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_fromstring at 0x7ff8ef2fb0d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2ec550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2ec2d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromstring(): module = self.import_extension('foo', [ ("from_string", "METH_NOARGS", """ PyObject* str = PyUnicode_FromString("1234.56"); PyObject* res = PyFloat_FromString(str); Py_DECREF(str); return res; """), ]) assert module.from_string() == 1234.56 assert type(module.from_string()) is float try: test_fromstring() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestFloatObject.test_return_nan ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3650d0>, 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_return_nan'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_nan'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_return_nan'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_nan'>} 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_return_nan'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_nan'>} 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_return_nan'>, '__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 0x7ff8ee247640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_nan'>, '__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 0x7ff8ee2476e0> 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 0x7ff8ee2476e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_nan'>, '__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_return_nan'>, '__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 0x7ff8ee2477d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_nan'>, '__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 0x7ff8ee247730> 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 0x7ff8ee247730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_nan'>, '__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_return_nan'>, '__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_return_nan'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_return_nan'> 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_return_nan at 0x7ff8ef2fb150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2c2c10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2c2e90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_return_nan(): import math module = self.import_extension('foo', [ ("return_nan", "METH_NOARGS", "Py_RETURN_NAN;"), ]) assert math.isnan(module.return_nan()) try: test_return_nan() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestFloatObject.test_return_inf ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee39d2d0>, 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_return_inf'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_inf'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_return_inf'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_inf'>} 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_return_inf'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_inf'>} 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_return_inf'>, '__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 0x7ff8ee2fc460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_inf'>, '__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 0x7ff8ee2fccd0> 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 0x7ff8ee2fccd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_inf'>, '__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_return_inf'>, '__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 0x7ff8ee2fca00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_inf'>, '__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 0x7ff8ee2fc730> 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 0x7ff8ee2fc730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...return_inf'>, '__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_return_inf'>, '__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_return_inf'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_return_inf'> 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_return_inf at 0x7ff8ef2fb1d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2c9f10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2c9410> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_return_inf(): import math module = self.import_extension('foo', [ ("return_inf", "METH_NOARGS", "Py_RETURN_INF(10);"), ]) inf = module.return_inf() assert inf > 0 assert math.isinf(inf) try: test_return_inf() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestFloatObject.test_return_inf_negative __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee423dd0>, 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_return_inf_negative'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_inf_negative'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_return_inf_negative'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_inf_negative'>} 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_return_inf_negative'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_return_inf_negative'>} 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_return_inf_negative'>, '__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 0x7ff8ee21b870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...f_negative'>, '__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 0x7ff8ee21b960> 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 0x7ff8ee21b960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...f_negative'>, '__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_return_inf_negative'>, '__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 0x7ff8ee21ba00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...f_negative'>, '__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 0x7ff8ee21baf0> 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 0x7ff8ee21baf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...f_negative'>, '__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_return_inf_negative'>, '__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_return_inf_negative'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_return_inf_negative'> 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_return_inf_negative at 0x7ff8ef2fb250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2ec750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee3ec7d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_return_inf_negative(): import math module = self.import_extension('foo', [ ("return_neginf", "METH_NOARGS", "Py_RETURN_INF(-10);"), ]) neginf = module.return_neginf() assert neginf < 0 assert math.isinf(neginf) try: test_return_inf_negative() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________ AppTestFloatObject.test_macro_accepts_wrong_pointer_type ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee4ce150>, 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_macro_accepts_wrong_pointer_typ...l__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_accepts_wrong_pointer_type'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_macro_accepts_wrong_pointer_typ...l__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_accepts_wrong_pointer_type'>} 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_macro_accepts_wrong_pointer_typ...l__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_macro_accepts_wrong_pointer_type'>} 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_macro_accepts_wrong_pointer_type'>, '__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 0x7ff8ee4e5aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...inter_type'>, '__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 0x7ff8ee21b2d0> 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 0x7ff8ee21b2d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...inter_type'>, '__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_macro_accepts_wrong_pointer_type'>, '__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 0x7ff8ee24b820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...inter_type'>, '__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 0x7ff8ee24b140> 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 0x7ff8ee24b140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...inter_type'>, '__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_macro_accepts_wrong_pointer_type'>, '__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_macro_accepts_wrong_pointer_type'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_macro_accepts_wrong_pointer_type'> 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_macro_accepts_wrong_pointer_type at 0x7ff8ef2fb2d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2c9610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2c9150> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_macro_accepts_wrong_pointer_type(): module = self.import_extension('foo', [ ("test_macros", "METH_NOARGS", """ PyObject* o = PyFloat_FromDouble(1.0); // no PyFloatObject char* dumb_pointer = (char*)o; PyFloat_AS_DOUBLE(o); PyFloat_AS_DOUBLE(dumb_pointer); Py_RETURN_NONE;"""), ]) try: test_macro_accepts_wrong_pointer_type() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestFloatObject.test_PyFloat_Check _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee423dd0>, 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_PyFloat_Check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyFloat_Check'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyFloat_Check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyFloat_Check'>} 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_PyFloat_Check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyFloat_Check'>} 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_PyFloat_Check'>, '__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 0x7ff8ee312780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...loat_Check'>, '__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 0x7ff8ee36cf00> 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 0x7ff8ee36cf00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...loat_Check'>, '__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_PyFloat_Check'>, '__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 0x7ff8ee36cb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...loat_Check'>, '__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 0x7ff8ee36c500> 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 0x7ff8ee36c500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...loat_Check'>, '__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_PyFloat_Check'>, '__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_PyFloat_Check'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyFloat_Check'> 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_PyFloat_Check at 0x7ff8ef2fb350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2c65d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2c6250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyFloat_Check(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ PyObject* pyobj = PyFloat_FromDouble(1.0); PyFloatObject* pfo = (PyFloatObject*)pyobj; int res = (PyFloat_Check(pyobj) + PyFloat_CheckExact(pyobj) * 10 + PyFloat_Check(pfo) * 100 + PyFloat_CheckExact(pfo) * 1000); Py_DecRef(pyobj); return PyLong_FromLong(res);"""), ]) assert module.test() == 1111 try: test_PyFloat_Check() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestFloatObject.test_pymath_consts _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee4ce150>, 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_pymath_consts'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pymath_consts'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pymath_consts'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pymath_consts'>} 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_pymath_consts'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pymath_consts'>} 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_pymath_consts'>, '__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 0x7ff8ee22a320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ath_consts'>, '__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 0x7ff8ee22a500> 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 0x7ff8ee22a500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ath_consts'>, '__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_pymath_consts'>, '__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 0x7ff8ee22a5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ath_consts'>, '__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 0x7ff8ee22a690> 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 0x7ff8ee22a690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ath_consts'>, '__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_pymath_consts'>, '__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_pymath_consts'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pymath_consts'> 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_pymath_consts at 0x7ff8ef2fb3d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2c6590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2ec590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pymath_consts(): # test preprocessor constants in their string form to avoid # floating-point conversion issues (and to avoid having to # conditionalize on compiler support for long double) for const_name, const_strval in [ ('Py_MATH_PIl', b"3.1415926535897932384626433832795029L"), ('Py_MATH_PI', b"3.14159265358979323846"), ('Py_MATH_El', b"2.7182818284590452353602874713526625L"), ('Py_MATH_E', b"2.7182818284590452354"), ('Py_MATH_TAU', b"6.2831853071795864769252867665590057683943L"), ]: module = self.import_extension('foo_%s' % const_name, [ ("test", "METH_NOARGS", """ #define xstr(s) str(s) #define str(s) #s return PyBytes_FromString(xstr(%s));""" % const_name) ]) assert module.test() == const_strval try: test_pymath_consts() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestFloatObject.test_Py_IS _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee423dd0>, 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_Py_IS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_IS'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Py_IS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_IS'>} 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_Py_IS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_IS'>} 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_Py_IS'>, '__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 0x7ff8ee21b6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_IS'>, '__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 0x7ff8ee21b730> 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 0x7ff8ee21b730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_IS'>, '__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_Py_IS'>, '__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 0x7ff8ee21bf00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_IS'>, '__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 0x7ff8ee21b4b0> 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 0x7ff8ee21b4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_IS'>, '__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_Py_IS'>, '__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_Py_IS'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Py_IS'> 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_Py_IS at 0x7ff8ef2fb450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee239fd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee239dd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Py_IS(): module = self.import_extension('foo', [ ("test_nan", "METH_O", """ double d = PyFloat_AsDouble(args); return PyBool_FromLong(Py_IS_NAN(d)); """), ("test_inf", "METH_O", """ double d = PyFloat_AsDouble(args); return PyBool_FromLong(Py_IS_INFINITY(d)); """), ("test_finite", "METH_O", """ double d = PyFloat_AsDouble(args); return PyBool_FromLong(Py_IS_FINITE(d)); """), ]) assert not module.test_nan(0) assert not module.test_nan(1) assert not module.test_nan(-1) assert not module.test_nan(float('inf')) assert module.test_nan(float('nan')) assert not module.test_inf(0) assert not module.test_inf(1) assert not module.test_inf(-1) assert not module.test_inf(float('nan')) assert module.test_inf(float('inf')) assert module.test_inf(float('-inf')) assert module.test_finite(0) assert module.test_finite(1) assert module.test_finite(-1) assert not module.test_finite(float('nan')) assert not module.test_finite(float('inf')) assert not module.test_finite(float('-inf')) try: test_Py_IS() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestFloatObject.test_Py_Float_AsDouble ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2cf3d0>, 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_Py_Float_AsDouble'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_Float_AsDouble'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Py_Float_AsDouble'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_Float_AsDouble'>} 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_Py_Float_AsDouble'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_Float_AsDouble'>} 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_Py_Float_AsDouble'>, '__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 0x7ff8ee22a500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsDouble'>, '__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 0x7ff8ee22ac30> 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 0x7ff8ee22ac30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsDouble'>, '__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_Py_Float_AsDouble'>, '__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 0x7ff8ee22ae60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsDouble'>, '__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 0x7ff8ee22ad20> 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 0x7ff8ee22ad20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_AsDouble'>, '__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_Py_Float_AsDouble'>, '__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_Py_Float_AsDouble'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Py_Float_AsDouble'> 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_Py_Float_AsDouble at 0x7ff8ef2fb4d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2c6d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2c6e10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Py_Float_AsDouble(): import warnings module = self.import_extension('foo', [ ("test", "METH_O", """ double d = PyFloat_AsDouble(args); if (PyErr_Occurred()) { return NULL; } return PyFloat_FromDouble(d); """), ]) try: module.test([]) except Exception as e: print(str(e)) assert str(e) == 'must be real number, not list' else: assert False class Floatsub(float): pass class BadFloat: def __float__(self): return Floatsub(4.25) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always", DeprecationWarning) res = module.test(BadFloat()) assert res == 4.25 assert len(w) == 1 assert "strict subclass" in str(w[0]), str(w[0]) try: test_Py_Float_AsDouble() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestFloatObject.test_Py_HUGE_VAL ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3652d0>, 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_Py_HUGE_VAL'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_HUGE_VAL'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Py_HUGE_VAL'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_HUGE_VAL'>} 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_Py_HUGE_VAL'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_HUGE_VAL'>} 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_Py_HUGE_VAL'>, '__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 0x7ff8ee2015f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_HUGE_VAL'>, '__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 0x7ff8ee2016e0> 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 0x7ff8ee2016e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_HUGE_VAL'>, '__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_Py_HUGE_VAL'>, '__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 0x7ff8ee201780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_HUGE_VAL'>, '__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 0x7ff8ee201870> 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 0x7ff8ee201870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_HUGE_VAL'>, '__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_Py_HUGE_VAL'>, '__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_Py_HUGE_VAL'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Py_HUGE_VAL'> 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_Py_HUGE_VAL at 0x7ff8ef2fb550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee239a90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2d6f10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Py_HUGE_VAL(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ return PyFloat_FromDouble(Py_HUGE_VAL); """), ]) assert module.test() == float('inf') try: test_Py_HUGE_VAL() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestFloatObject.test_Py_NAN ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee39d650>, 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_Py_NAN'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_NAN'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Py_NAN'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_NAN'>} 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_Py_NAN'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_NAN'>} 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_Py_NAN'>, '__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 0x7ff8ee1e3690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Py_NAN'>, '__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 0x7ff8ee1e3550> 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 0x7ff8ee1e3550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Py_NAN'>, '__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_Py_NAN'>, '__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 0x7ff8ee1e3640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Py_NAN'>, '__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 0x7ff8ee21b230> 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 0x7ff8ee21b230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Py_NAN'>, '__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_Py_NAN'>, '__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_Py_NAN'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Py_NAN'> 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_Py_NAN at 0x7ff8ef2fb5d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee2243d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee224190> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Py_NAN(): import sys module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ return PyFloat_FromDouble(Py_NAN); """), ]) if sys.platform == 'win32': # CPython does not enforce bit-compatibility between the NANs import math assert math.isnan(module.test()) else: import struct float_bits = struct.Struct('d').pack assert float_bits(module.test()) == float_bits(float('nan')) try: test_Py_NAN() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestFloatObject.test_roundtrip _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2ff1d0>, 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_roundtrip'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_roundtrip'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_roundtrip'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_roundtrip'>} 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_roundtrip'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_roundtrip'>} 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_roundtrip'>, '__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 0x7ff8ee1c9550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._roundtrip'>, '__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 0x7ff8ee1c95f0> 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 0x7ff8ee1c95f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._roundtrip'>, '__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_roundtrip'>, '__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 0x7ff8ee1c96e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._roundtrip'>, '__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 0x7ff8ee1c9640> 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 0x7ff8ee1c9640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._roundtrip'>, '__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_roundtrip'>, '__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_roundtrip'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_roundtrip'> 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_roundtrip at 0x7ff8ef2fb650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFloatObject.w_compile_module of <pypy.module.cpyext.test.test_floatobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_floatobject.AppTestFloatObject object at 0x7ff8ee21fa10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee224250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_roundtrip(): module = self.import_extension('foo', [ ("float_pack", "METH_VARARGS", """ int size; double d; int le; if (!PyArg_ParseTuple(args, "idi", &size, &d, &le)) { return NULL; } switch (size) { case 2: { char data[2]; if (PyFloat_Pack2(d, data, le) < 0) { return NULL; } return PyBytes_FromStringAndSize(data, Py_ARRAY_LENGTH(data)); } case 4: { char data[4]; if (PyFloat_Pack4(d, data, le) < 0) { return NULL; } return PyBytes_FromStringAndSize(data, Py_ARRAY_LENGTH(data)); } case 8: { char data[8]; if (PyFloat_Pack8(d, data, le) < 0) { return NULL; } return PyBytes_FromStringAndSize(data, Py_ARRAY_LENGTH(data)); } default: break; } PyErr_SetString(PyExc_ValueError, "size must 2, 4 or 8"); return NULL; """), ("float_unpack", "METH_VARARGS", """ assert(!PyErr_Occurred()); const char *data; Py_ssize_t size; int le; if (!PyArg_ParseTuple(args, "y#i", &data, &size, &le)) { return NULL; } double d; switch (size) { case 2: d = PyFloat_Unpack2(data, le); break; case 4: d = PyFloat_Unpack4(data, le); break; case 8: d = PyFloat_Unpack8(data, le); break; default: PyErr_SetString(PyExc_ValueError, "data length must 2, 4 or 8 bytes"); return NULL; } if (d == -1.0 && PyErr_Occurred()) { return NULL; } return PyFloat_FromDouble(d); """), ], PY_SSIZE_T_CLEAN=1) import math HAVE_IEEE_754 = float.__getformat__("double").startswith("IEEE") INF = float("inf") NAN = float("nan") BIG_ENDIAN = 0 LITTLE_ENDIAN = 1 EPSILON = { 2: 2.0 ** -11, # binary16 4: 2.0 ** -24, # binary32 8: 2.0 ** -53, # binary64 } large = 2.0 ** 100 values = [1.0, 1.5, large, 1.0/7, math.pi] if HAVE_IEEE_754: values.extend((INF, NAN)) for value in values: for size in (2, 4, 8,): if size == 2 and value == large: # too large for 16-bit float continue rel_tol = EPSILON[size] for endian in (BIG_ENDIAN, LITTLE_ENDIAN): data = module.float_pack(size, value, endian) value2 = module.float_unpack(data, endian) if math.isnan(value): assert math.isnan(value2), (value, value2) elif size < 8: assert math.isclose(value2, value, rel_tol=rel_tol), (value, value2) else: assert value2 == value try: test_roundtrip() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestFrameObject.test_forge_frame ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee394450>, 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_forge_frame'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forge_frame'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_forge_frame'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forge_frame'>} 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_forge_frame'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forge_frame'>} 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_forge_frame'>, '__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 0x7ff8ee1b55f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orge_frame'>, '__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 0x7ff8ee1b56e0> 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 0x7ff8ee1b56e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orge_frame'>, '__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_forge_frame'>, '__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 0x7ff8ee1b5780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orge_frame'>, '__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 0x7ff8ee1b5870> 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 0x7ff8ee1b5870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orge_frame'>, '__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_forge_frame'>, '__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_forge_frame'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_forge_frame'> 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_forge_frame at 0x7ff8ef2570d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFrameObject.w_compile_module of <pypy.module.cpyext.test.test_frameobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_frameobject.AppTestFrameObject object at 0x7ff8ee21f790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2d6ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_forge_frame(): module = self.import_extension('foo', [ ("raise_exception", "METH_NOARGS", """ PyObject *py_srcfile = PyUnicode_FromString("filename"); PyObject *py_funcname = PyUnicode_FromString("funcname"); PyObject *py_globals = PyDict_New(); PyObject *py_locals = PyDict_New(); PyObject *empty_bytes = PyBytes_FromString(""); PyObject *empty_tuple = PyTuple_New(0); PyCodeObject *py_code; PyFrameObject *py_frame = NULL; py_code = (PyCodeObject *)PyCode_New( 0, /*int argcount,*/ #if PY_MAJOR_VERSION >= 3 0, /*int kwonlyargcount,*/ #endif 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ empty_bytes, /*PyObject *code,*/ empty_tuple, /*PyObject *consts,*/ empty_tuple, /*PyObject *names,*/ empty_tuple, /*PyObject *varnames,*/ empty_tuple, /*PyObject *freevars,*/ empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *qualname,*/ py_funcname, /*PyObject *name,*/ 42, /*int firstlineno,*/ empty_bytes /*PyObject *lnotab*/ ); if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ py_locals /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = 48; /* Does not work with CPython */ PyErr_SetString(PyExc_ValueError, "error message"); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); Py_XDECREF(empty_bytes); Py_XDECREF(empty_tuple); Py_XDECREF(py_globals); Py_XDECREF(py_locals); Py_XDECREF(py_code); Py_XDECREF(py_frame); return NULL; """), ], prologue='#include "frameobject.h"') exc = raises(ValueError, module.raise_exception) exc.value.args[0] == 'error message' frame = exc.traceback.tb_frame if not self.runappdirect: frame = exc.traceback.tb_frame assert frame.f_code.co_filename == "filename" assert frame.f_code.co_name == "funcname" # Cython does not work on CPython as well... assert exc.traceback.tb_lineno in (-1, 42, 48) # should be 48 assert frame.f_lineno in (-1, 42, 48) try: test_forge_frame() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestFrameObject.test_forge_frame_newer ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee39d7d0>, 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_forge_frame_newer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forge_frame_newer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_forge_frame_newer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forge_frame_newer'>} 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_forge_frame_newer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forge_frame_newer'>} 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_forge_frame_newer'>, '__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 0x7ff8ee1b1320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rame_newer'>, '__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 0x7ff8ee1b1500> 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 0x7ff8ee1b1500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rame_newer'>, '__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_forge_frame_newer'>, '__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 0x7ff8ee1b15f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rame_newer'>, '__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 0x7ff8ee1b1690> 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 0x7ff8ee1b1690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rame_newer'>, '__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_forge_frame_newer'>, '__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_forge_frame_newer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_forge_frame_newer'> 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_forge_frame_newer at 0x7ff8ef257150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFrameObject.w_compile_module of <pypy.module.cpyext.test.test_frameobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_frameobject.AppTestFrameObject object at 0x7ff8ee1cb710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1cb890> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_forge_frame_newer(): module = self.import_extension('foo', [ ("raise_exception", "METH_NOARGS", """ PyCodeObject *py_code = NULL; PyFrameObject *py_frame = NULL; PyObject *py_globals = NULL; py_code = PyCode_NewEmpty( "filename", "funcname", 42); py_globals = PyDict_New(); py_frame = PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ NULL /*PyObject *locals*/ ); PyErr_SetString(PyExc_ValueError, "error message"); PyTraceBack_Here(py_frame); Py_XDECREF(py_globals); Py_XDECREF(py_code); Py_XDECREF(py_frame); return NULL; """), ], prologue='#include "frameobject.h"') exc = raises(ValueError, module.raise_exception) exc.value.args[0] == 'error message' frame = exc.traceback.tb_frame if not self.runappdirect: assert frame.f_code.co_filename == "filename" assert frame.f_code.co_name == "funcname" assert exc.traceback.tb_lineno == 42 assert frame.f_lineno == 42 try: test_forge_frame_newer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestFrameObject.test_traceback_check ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee394450>, 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_traceback_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_traceback_check'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_traceback_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_traceback_check'>} 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_traceback_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_traceback_check'>} 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_traceback_check'>, '__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 0x7ff8ee18f780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...back_check'>, '__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 0x7ff8ee18f960> 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 0x7ff8ee18f960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...back_check'>, '__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_traceback_check'>, '__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 0x7ff8ee18fa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...back_check'>, '__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 0x7ff8ee18faf0> 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 0x7ff8ee18faf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...back_check'>, '__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_traceback_check'>, '__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_traceback_check'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_traceback_check'> 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_traceback_check at 0x7ff8ef2571d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFrameObject.w_compile_module of <pypy.module.cpyext.test.test_frameobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_frameobject.AppTestFrameObject object at 0x7ff8ee4fb950>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee4fbd10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_traceback_check(): module = self.import_extension('foo', [ ("traceback_check", "METH_NOARGS", """ int check; PyObject *type, *value, *tb; PyObject *ret = PyRun_String("XXX", Py_eval_input, Py_None, Py_None); if (ret) { Py_DECREF(ret); PyErr_SetString(PyExc_AssertionError, "should raise"); return NULL; } PyErr_Fetch(&type, &value, &tb); if (tb == NULL) { Py_XDECREF(type); Py_XDECREF(value); PyErr_SetString(PyExc_AssertionError, "No traceback"); return NULL; } check = PyTraceBack_Check(tb); Py_XDECREF(type); Py_XDECREF(value); Py_XDECREF(tb); if (check) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } """), ]) # On CPython the traceback is NULL assert module.traceback_check() try: test_traceback_check() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestFrameObject.test_get_xxx ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee33a1d0>, 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_get_xxx'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_xxx'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_get_xxx'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_xxx'>} 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_get_xxx'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_xxx'>} 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_get_xxx'>, '__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 0x7ff8ee183500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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 0x7ff8ee183460> 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 0x7ff8ee183460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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_get_xxx'>, '__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 0x7ff8ee1835a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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 0x7ff8ee183640> 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 0x7ff8ee183640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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_get_xxx'>, '__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_get_xxx'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_get_xxx'> 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_get_xxx at 0x7ff8ef257250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFrameObject.w_compile_module of <pypy.module.cpyext.test.test_frameobject.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_frameobject.AppTestFrameObject object at 0x7ff8ee2242d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1cb390> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_get_xxx(): module = self.import_extension('foo', [ ("frame_getlocals", "METH_O", """ if (!PyFrame_Check(args)) { PyErr_SetString(PyExc_TypeError, "argument must be a frame"); return NULL; } return PyFrame_GetLocals((PyFrameObject *)args); """), ("frame_getglobals", "METH_O", """ if (!PyFrame_Check(args)) { PyErr_SetString(PyExc_TypeError, "argument must be a frame"); return NULL; } return PyFrame_GetGlobals((PyFrameObject *)args); """), ("frame_getgenerator", "METH_O", """ if (!PyFrame_Check(args)) { PyErr_SetString(PyExc_TypeError, "argument must be a frame"); return NULL; } return PyFrame_GetGenerator((PyFrameObject *)args); """), ("frame_getbuiltins", "METH_O", """ if (!PyFrame_Check(args)) { PyErr_SetString(PyExc_TypeError, "argument must be a frame"); return NULL; } return PyFrame_GetBuiltins((PyFrameObject *)args); """), ("frame_getlasti", "METH_O", """ if (!PyFrame_Check(args)) { PyErr_SetString(PyExc_TypeError, "argument must be a frame"); return NULL; } int lasti = PyFrame_GetLasti((PyFrameObject *)args); if (lasti < 0) { assert(lasti == -1); Py_RETURN_NONE; } return PyLong_FromLong(lasti); """), ("frame_getlinenumber", "METH_O", """ if (!PyFrame_Check(args)) { PyErr_SetString(PyExc_TypeError, "argument must be a frame"); return NULL; } int num = PyFrame_GetLineNumber((PyFrameObject *)args); if (num < 0) { Py_RETURN_NONE; } return PyLong_FromLong(num); """), ]) import sys frame = sys._getframe() assert frame.f_locals == module.frame_getlocals(frame) assert frame.f_globals == module.frame_getglobals(frame) assert frame.f_builtins == module.frame_getbuiltins(frame) lasti = module.frame_getlasti(frame) assert abs(frame.f_lasti - lasti) < 40 assert frame.f_lineno == module.frame_getlinenumber(frame) def getgenframe(): yield sys._getframe() gen = getgenframe() frame = next(gen) assert gen == module.frame_getgenerator(frame) try: test_get_xxx() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______ AppTestPickleCpyextFunction.test_pickle_cpyext_function_directly _______ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee39d650>, 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_pickle_cpyext_function_directly...ll__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_cpyext_function_directly'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pickle_cpyext_function_directly...ll__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_cpyext_function_directly'>} 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_pickle_cpyext_function_directly...ll__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_cpyext_function_directly'>} 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_pickle_cpyext_function_directly'>, '__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 0x7ff8ee1830f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...n_directly'>, '__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 0x7ff8ee2015a0> 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 0x7ff8ee2015a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...n_directly'>, '__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_pickle_cpyext_function_directly'>, '__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 0x7ff8ee201eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...n_directly'>, '__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 0x7ff8ee2015f0> 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 0x7ff8ee2015f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...n_directly'>, '__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_pickle_cpyext_function_directly'>, '__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_pickle_cpyext_function_directly'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pickle_cpyext_function_directly'> 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_pickle_cpyext_function_directly at 0x7ff8ef24c850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPickleCpyextFunction.w_compile_module of <pypy.module.cpyext.test.test_funcobj...port_extension of <pypy.module.cpyext.test.test_funcobject.AppTestPickleCpyextFunction object at 0x7ff8ee1cb7d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1cb610> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pickle_cpyext_function_directly(): # Regression for issue #5445. # pickle.py registered _Pickler.save_global (an unbound method needing # self and obj) in copyreg.dispatch_table for cpyext.FunctionType. # Pickling any cpyext function raised: # TypeError: _Pickler.save_global() missing 1 required positional argument: 'obj' module = self.import_extension('pickle_cpyext_test', [ ("identity", "METH_O", """ Py_INCREF(args); return args; """), ]) import _pickle for proto in range(6): data = _pickle.dumps(module.identity, proto) result = _pickle.loads(data) assert result is module.identity # Also test via the high-level pickle module, which imports pickle.py # and previously installed a broken copyreg.dispatch_table entry that # caused the same TypeError when _pickle then looked it up. import pickle for proto in range(6): data = pickle.dumps(module.identity, protocol=proto) result = pickle.loads(data) assert result is module.identity try: test_pickle_cpyext_function_directly() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___ AppTestPickleCpyextFunction.test_pickle_reduce_returning_cpyext_function ___ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee33a1d0>, 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_pickle_reduce_returning_cpyext_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_reduce_returning_cpyext_function'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pickle_reduce_returning_cpyext_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_reduce_returning_cpyext_function'>} 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_pickle_reduce_returning_cpyext_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_reduce_returning_cpyext_function'>} 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_pickle_reduce_returning_cpyext_function'>, '__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 0x7ff8ee1b7500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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 0x7ff8ee1b7780> 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 0x7ff8ee1b7780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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_pickle_reduce_returning_cpyext_function'>, '__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 0x7ff8ee1b7870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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 0x7ff8ee1b7910> 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 0x7ff8ee1b7910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_function'>, '__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_pickle_reduce_returning_cpyext_function'>, '__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_pickle_reduce_returning_cpyext_function'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pickle_reduce_returning_cpyext_function'> 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_pickle_reduce_returning_cpyext_function at 0x7ff8ef24c8d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPickleCpyextFunction.w_compile_module of <pypy.module.cpyext.test.test_funcobj...port_extension of <pypy.module.cpyext.test.test_funcobject.AppTestPickleCpyextFunction object at 0x7ff8ee1cb3d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1e2b10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pickle_reduce_returning_cpyext_function(): # Regression for issue #5445: object whose __reduce__ returns a cpyext # function as the callable also triggered the TypeError. module = self.import_extension('pickle_cpyext_reduce_test', [ ("add_one", "METH_O", """ long n = PyLong_AsLong(args); if (n == -1 && PyErr_Occurred()) return NULL; return PyLong_FromLong(n + 1); """), ]) import _pickle class Container: def __reduce__(self): return module.add_one, (41,) for proto in range(6): result = _pickle.loads(_pickle.dumps(Container(), proto)) assert result == 42 try: test_pickle_reduce_returning_cpyext_function() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________ AppTestPickleCpyextFunction.test_pickle_method_descriptor ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee39d650>, 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_pickle_method_descriptor'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_method_descriptor'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pickle_method_descriptor'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_method_descriptor'>} 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_pickle_method_descriptor'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_method_descriptor'>} 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_pickle_method_descriptor'>, '__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 0x7ff8ee1585f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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 0x7ff8ee158870> 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 0x7ff8ee158870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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_pickle_method_descriptor'>, '__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 0x7ff8ee158960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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 0x7ff8ee158a00> 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 0x7ff8ee158a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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_pickle_method_descriptor'>, '__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_pickle_method_descriptor'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pickle_method_descriptor'> 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_pickle_method_descriptor at 0x7ff8ef24c950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPickleCpyextFunction.w_compile_module of <pypy.module.cpyext.test.test_funcobj...port_extension of <pypy.module.cpyext.test.test_funcobject.AppTestPickleCpyextFunction object at 0x7ff8ee1ff950>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1ff350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pickle_method_descriptor(): # method_descriptor (W_PyCMethodObject): unbound method on a C extension type, # e.g. MyType.my_method. Should pickle as (getattr, (MyType, 'my_method')). module = self.import_extension('pickle_method_desc', [ ("new_obj", "METH_NOARGS", """ PyObject *obj = PyObject_New(PyObject, &Foo_Type); return obj; """), ], prologue=""" static PyObject * foo_greet(PyObject *self, PyObject *args) { return PyLong_FromLong(42); } static PyMethodDef foo_methods[] = { {"greet", foo_greet, METH_NOARGS, NULL}, {NULL} }; static PyTypeObject Foo_Type = { PyVarObject_HEAD_INIT(NULL, 0) "pickle_method_desc.Foo", }; """, more_init=""" Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; Foo_Type.tp_methods = foo_methods; if (PyType_Ready(&Foo_Type) < 0) INITERROR; PyModule_AddObject(mod, "Foo", (PyObject *)&Foo_Type); """) import _pickle # module.Foo.greet is a method_descriptor (W_PyCMethodObject) for proto in range(6): data = _pickle.dumps(module.Foo.greet, proto) result = _pickle.loads(data) assert result is module.Foo.greet try: test_pickle_method_descriptor() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________ AppTestPickleCpyextFunction.test_pickle_classmethod_descriptor ________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee33a1d0>, 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_pickle_classmethod_descriptor'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_classmethod_descriptor'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pickle_classmethod_descriptor'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_classmethod_descriptor'>} 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_pickle_classmethod_descriptor'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_classmethod_descriptor'>} 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_pickle_classmethod_descriptor'>, '__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 0x7ff8ee3d1fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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 0x7ff8ee3d1820> 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 0x7ff8ee3d1820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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_pickle_classmethod_descriptor'>, '__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 0x7ff8ee3d1eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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 0x7ff8ee1b7460> 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 0x7ff8ee1b7460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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_pickle_classmethod_descriptor'>, '__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_pickle_classmethod_descriptor'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pickle_classmethod_descriptor'> 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_pickle_classmethod_descriptor at 0x7ff8ef24c9d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPickleCpyextFunction.w_compile_module of <pypy.module.cpyext.test.test_funcobj...port_extension of <pypy.module.cpyext.test.test_funcobject.AppTestPickleCpyextFunction object at 0x7ff8ee1ff0d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1fffd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pickle_classmethod_descriptor(): # classmethod on a C extension type (W_PyCClassMethodObject). # Should pickle as (getattr, (MyType, 'from_int')). module = self.import_extension('pickle_classmethod_desc', [ ("new_obj", "METH_NOARGS", """ PyObject *obj = PyObject_New(PyObject, &Foo_Type); return obj; """), ], prologue=""" static PyObject * foo_from_int(PyObject *cls, PyObject *args) { return PyLong_FromLong(99); } static PyMethodDef foo_methods[] = { {"from_int", foo_from_int, METH_NOARGS | METH_CLASS, NULL}, {NULL} }; static PyTypeObject Foo_Type = { PyVarObject_HEAD_INIT(NULL, 0) "pickle_classmethod_desc.Foo", }; """, more_init=""" Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; Foo_Type.tp_methods = foo_methods; if (PyType_Ready(&Foo_Type) < 0) INITERROR; PyModule_AddObject(mod, "Foo", (PyObject *)&Foo_Type); """) import _pickle # module.Foo.from_int is a W_PyCClassMethodObject for proto in range(6): data = _pickle.dumps(module.Foo.from_int, proto) result = _pickle.loads(data) assert result.__qualname__ == "Foo.from_int" try: test_pickle_classmethod_descriptor() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________ AppTestPickleCpyextFunction.test_pickle_wrapper_descriptor __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee39d650>, 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_pickle_wrapper_descriptor'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_wrapper_descriptor'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pickle_wrapper_descriptor'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_wrapper_descriptor'>} 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_pickle_wrapper_descriptor'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pickle_wrapper_descriptor'>} 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_pickle_wrapper_descriptor'>, '__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 0x7ff8ee177690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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 0x7ff8ee177910> 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 0x7ff8ee177910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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_pickle_wrapper_descriptor'>, '__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 0x7ff8ee177a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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 0x7ff8ee177aa0> 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 0x7ff8ee177aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...descriptor'>, '__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_pickle_wrapper_descriptor'>, '__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_pickle_wrapper_descriptor'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pickle_wrapper_descriptor'> 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_pickle_wrapper_descriptor at 0x7ff8ef24ca50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPickleCpyextFunction.w_compile_module of <pypy.module.cpyext.test.test_funcobj...port_extension of <pypy.module.cpyext.test.test_funcobject.AppTestPickleCpyextFunction object at 0x7ff8ee1bf8d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1ffd10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pickle_wrapper_descriptor(): # wrapper_descriptor (W_PyCWrapperObject): slot wrapper on a C extension # type, e.g. MyType.__repr__. Should pickle as (getattr, (MyType, '__repr__')). module = self.import_extension('pickle_wrapper_desc', [ ("new_obj", "METH_NOARGS", """ PyObject *obj = PyObject_New(PyObject, &Foo_Type); return obj; """), ], prologue=""" static PyObject * foo_repr(PyObject *self) { return PyUnicode_FromString("<Foo>"); } static PyTypeObject Foo_Type = { PyVarObject_HEAD_INIT(NULL, 0) "pickle_wrapper_desc.Foo", }; """, more_init=""" Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; Foo_Type.tp_repr = foo_repr; if (PyType_Ready(&Foo_Type) < 0) INITERROR; PyModule_AddObject(mod, "Foo", (PyObject *)&Foo_Type); """) import _pickle # module.Foo.__repr__ is a wrapper_descriptor (W_PyCWrapperObject) for proto in range(6): data = _pickle.dumps(module.Foo.__repr__, proto) result = _pickle.loads(data) assert result is module.Foo.__repr__ try: test_pickle_wrapper_descriptor() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestCall.test_code_new_empty ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee33a1d0>, 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_code_new_empty'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_code_new_empty'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_code_new_empty'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_code_new_empty'>} 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_code_new_empty'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_code_new_empty'>} 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_code_new_empty'>, '__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 0x7ff8ee1a8960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._new_empty'>, '__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 0x7ff8ee1a8be0> 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 0x7ff8ee1a8be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._new_empty'>, '__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_code_new_empty'>, '__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 0x7ff8ee1a8fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._new_empty'>, '__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 0x7ff8ee1a8b40> 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 0x7ff8ee1a8b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._new_empty'>, '__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_code_new_empty'>, '__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_code_new_empty'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_code_new_empty'> 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_code_new_empty at 0x7ff8ef24cad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_funcobject.AppTestCall ...AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_funcobject.AppTestCall object at 0x7ff8ee1fff10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1ffb90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_code_new_empty(): module = self.import_extension('foo', [ ("code_newempty", "METH_VARARGS", """ const char *filename; const char *funcname; int firstlineno; if (!PyArg_ParseTuple(args, "ssi:code_newempty", &filename, &funcname, &firstlineno)) return NULL; return (PyObject *)PyCode_NewEmpty(filename, funcname, firstlineno); """), ]) def f(): return args # check that calling a code object constructed by PyCode_NewEmpty # doesn't crash, and produce the right file, lineno, etc if not self.runappdirect: # The exception mocking for appdirect doesn't work well enough f.__code__ = module.code_newempty("abc", "def", 23) with raises(AssertionError) as info: f() lines = list(f.__code__.co_lines()) assert lines == [(0, 4, 23)] assert info.tb.tb_next.tb_lineno == 23 try: test_code_new_empty() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________________ AppTestCall.test_get_xxx ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2e60d0>, 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_get_xxx'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_xxx'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_get_xxx'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_xxx'>} 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_get_xxx'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_xxx'>} 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_get_xxx'>, '__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 0x7ff8ee2f1e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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 0x7ff8ee1a8c80> 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 0x7ff8ee1a8c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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_get_xxx'>, '__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 0x7ff8ee1a8230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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 0x7ff8ee18f780> 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 0x7ff8ee18f780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_get_xxx'>, '__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_get_xxx'>, '__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_get_xxx'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_get_xxx'> 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_get_xxx at 0x7ff8ef24cb50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCall.w_compile_module of <pypy.module.cpyext.test.test_funcobject.AppTestCall ...AppTestCall.w_import_extension of <pypy.module.cpyext.test.test_funcobject.AppTestCall object at 0x7ff8ee191950>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1bbb90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_get_xxx(): module = self.import_extension('foo', [ ("code_numfree", "METH_O", """ PyCodeObject *code = (PyCodeObject*)PyFunction_GetCode(args); if (code == NULL) { return NULL; } size_t n = PyCode_GetNumFree(code); return PyLong_FromSize_t(n); """), ("code_cellvars", "METH_O", """ PyCodeObject *code = (PyCodeObject*)PyFunction_GetCode(args); if (code == NULL) { return NULL; } return PyCode_GetCellvars(code); """), ("code_code", "METH_O", """ PyCodeObject *code = (PyCodeObject*)PyFunction_GetCode(args); if (code == NULL) { return NULL; } return PyCode_GetCode(code); """), ("code_freevars", "METH_O", """ PyCodeObject *code = (PyCodeObject*)PyFunction_GetCode(args); if (code == NULL) { return NULL; } return PyCode_GetFreevars(code); """), ("code_varnames", "METH_O", """ PyCodeObject *code = (PyCodeObject*)PyFunction_GetCode(args); if (code == NULL) { return NULL; } return PyCode_GetVarnames(code); """), ("func_globals", "METH_O", """ return PyFunction_GetGlobals(args); """), ("func_name", "METH_O", """ return PyUnicode_FromString(PyEval_GetFuncName(args)); """), ]) g = 42 def wrapper(x): a = 5 global g g = 12 def func(x): return a, x code = wrapper.__code__ class A: def method_example(self): pass assert module.code_cellvars(wrapper) == ('a', ) assert module.code_numfree(wrapper) == 0 assert module.code_code(wrapper) == code.co_code assert module.code_freevars(wrapper) == code.co_freevars assert module.code_varnames(wrapper) == code.co_varnames assert module.func_globals(wrapper) == wrapper.__globals__ assert module.func_name(sum) == "sum" assert module.func_name(wrapper) == "wrapper" assert module.func_name(A.method_example) == "method_example" assert module.func_name(A().method_example) == "method_example" assert module.func_name(A) == "type" # type objects: return metatype name try: test_get_xxx() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestCoroutine.test_generator_coroutine ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3390d0>, 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_generator_coroutine'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_generator_coroutine'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_generator_coroutine'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_generator_coroutine'>} 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_generator_coroutine'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_generator_coroutine'>} 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_generator_coroutine'>, '__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 0x7ff8ee21b960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._coroutine'>, '__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 0x7ff8ee3f6aa0> 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 0x7ff8ee3f6aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._coroutine'>, '__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_generator_coroutine'>, '__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 0x7ff8ee1b1b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._coroutine'>, '__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 0x7ff8ee1b1140> 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 0x7ff8ee1b1140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._coroutine'>, '__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_generator_coroutine'>, '__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_generator_coroutine'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_generator_coroutine'> 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_generator_coroutine at 0x7ff8ef26aad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCoroutine.w_compile_module of <pypy.module.cpyext.test.test_genobject.AppTestC...routine.w_import_extension of <pypy.module.cpyext.test.test_genobject.AppTestCoroutine object at 0x7ff8ee179750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee191c50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_generator_coroutine(): module = self.import_extension('test_gen', [ ('is_coroutine', 'METH_O', ''' if (!PyGen_CheckExact(args)) Py_RETURN_NONE; PyObject* co = ((PyGenObject*)args)->gi_code; if (((PyCodeObject*)co)->co_flags & CO_ITERABLE_COROUTINE) Py_RETURN_TRUE; else Py_RETURN_FALSE; ''')]) def it(): yield 42 assert module.is_coroutine(it()) is False self.debug_collect() # don't crash while deallocating from types import coroutine assert module.is_coroutine(coroutine(it)()) is True try: test_generator_coroutine() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestCoroutine.test_await __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee148c50>, 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_await'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_await'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_await'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_await'>} 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_await'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_await'>} 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_await'>, '__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 0x7ff8ee294550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_await'>, '__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 0x7ff8ee2945f0> 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 0x7ff8ee2945f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_await'>, '__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_await'>, '__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 0x7ff8ee2946e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_await'>, '__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 0x7ff8ee294640> 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 0x7ff8ee294640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_await'>, '__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_await'>, '__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_await'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_await'> 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_ = "test_await(self): \n module = self.import_extension('test_coroutine', [\n ('await_', 'METH_O',\n ...NULL;\n '''),])\n async def f():\n pass\n raises(StopIteration, next, module.await_(f()))" usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCoroutine.w_compile_module of <pypy.module.cpyext.test.test_genobject.AppTestC...routine.w_import_extension of <pypy.module.cpyext.test.test_genobject.AppTestCoroutine object at 0x7ff8ee465210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee465710> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_await(): module = self.import_extension('test_coroutine', [ ('await_', 'METH_O', ''' PyAsyncMethods* am = args->ob_type->tp_as_async; if (am && am->am_await) { return am->am_await(args); } PyErr_SetString(PyExc_TypeError, "Not an awaitable"); return NULL; '''),]) async def f(): pass raises(StopIteration, next, module.await_(f())) try: test_await() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestGetargs.test_pyarg_parse_int ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2748d0>, 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_pyarg_parse_int'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_int'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_int'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_int'>} 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_pyarg_parse_int'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_int'>} 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_pyarg_parse_int'>, '__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 0x7ff8ee2979b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._parse_int'>, '__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 0x7ff8ee297aa0> 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 0x7ff8ee297aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._parse_int'>, '__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_pyarg_parse_int'>, '__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 0x7ff8ee297a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._parse_int'>, '__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 0x7ff8ee297b40> 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 0x7ff8ee297b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._parse_int'>, '__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_pyarg_parse_int'>, '__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_pyarg_parse_int'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_int'> 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_pyarg_parse_int at 0x7ff8ef3489d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee179d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee179250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_int(): """ The `i` format specifier can be used to parse an integer. """ oneargint = self.import_parser( ''' int l; if (!PyArg_ParseTuple(args, "i", &l)) { return NULL; } return PyLong_FromLong(l); ''') assert oneargint(1) == 1 raises(TypeError, oneargint, None) raises(TypeError, oneargint) try: test_pyarg_parse_int() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestGetargs.test_pyarg_parse_fromname ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3f27d0>, 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_pyarg_parse_fromname'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_fromname'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_fromname'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_fromname'>} 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_pyarg_parse_fromname'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_fromname'>} 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_pyarg_parse_fromname'>, '__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 0x7ff8ee177f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_fromname'>, '__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 0x7ff8ee177230> 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 0x7ff8ee177230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_fromname'>, '__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_pyarg_parse_fromname'>, '__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 0x7ff8ee177050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_fromname'>, '__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 0x7ff8ee177410> 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 0x7ff8ee177410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_fromname'>, '__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_pyarg_parse_fromname'>, '__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_pyarg_parse_fromname'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_fromname'> 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_pyarg_parse_fromname at 0x7ff8ef348a50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee1798d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee179650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_fromname(): """ The name of the function parsing the arguments can be given after a `:` in the argument format string. """ oneargandform = self.import_parser( ''' int l; if (!PyArg_ParseTuple(args, "i:oneargandstuff", &l)) { return NULL; } return PyLong_FromLong(l); ''') assert oneargandform(1) == 1 try: test_pyarg_parse_fromname() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestGetargs.test_pyarg_parse_object ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee4fe1d0>, 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_pyarg_parse_object'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_object'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_object'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_object'>} 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_pyarg_parse_object'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_object'>} 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_pyarg_parse_object'>, '__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 0x7ff8ee151870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rse_object'>, '__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 0x7ff8ee151280> 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 0x7ff8ee151280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rse_object'>, '__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_pyarg_parse_object'>, '__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 0x7ff8ee151cd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rse_object'>, '__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 0x7ff8ee1519b0> 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 0x7ff8ee1519b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rse_object'>, '__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_pyarg_parse_object'>, '__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_pyarg_parse_object'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_object'> 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_pyarg_parse_object at 0x7ff8ef348ad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee179c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee179910> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_object(): """ The `O` format specifier can be used to parse an arbitrary object. """ oneargobject = self.import_parser( ''' PyObject *obj; if (!PyArg_ParseTuple(args, "O", &obj)) { return NULL; } Py_INCREF(obj); return obj; ''') sentinel = object() res = oneargobject(sentinel) assert res is sentinel try: test_pyarg_parse_object() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________ AppTestGetargs.test_pyarg_parse_restricted_object_type ____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3f27d0>, 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_pyarg_parse_restricted_object_t..._': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_restricted_object_type'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_restricted_object_t..._': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_restricted_object_type'>} 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_pyarg_parse_restricted_object_t..._': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_restricted_object_type'>} 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_pyarg_parse_restricted_object_type'>, '__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 0x7ff8ee1007d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...bject_type'>, '__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 0x7ff8ee100870> 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 0x7ff8ee100870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...bject_type'>, '__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_pyarg_parse_restricted_object_type'>, '__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 0x7ff8ee100960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...bject_type'>, '__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 0x7ff8ee1008c0> 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 0x7ff8ee1008c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...bject_type'>, '__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_pyarg_parse_restricted_object_type'>, '__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_pyarg_parse_restricted_object_type'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_restricted_object_type'> 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_pyarg_parse_restricted_object_type at 0x7ff8ef348b50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee150550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee150f90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_restricted_object_type(): """ The `O!` format specifier can be used to parse an object of a particular type. """ oneargobjectandlisttype = self.import_parser( ''' PyObject *obj; if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &obj)) { return NULL; } Py_INCREF(obj); return obj; ''') sentinel = object() raises(TypeError, "oneargobjectandlisttype(sentinel)") sentinel = [] res = oneargobjectandlisttype(sentinel) assert res is sentinel try: test_pyarg_parse_restricted_object_type() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestGetargs.test_pyarg_parse_one_optional _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee18a950>, 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_pyarg_parse_one_optional'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_one_optional'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_one_optional'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_one_optional'>} 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_pyarg_parse_one_optional'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_one_optional'>} 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_pyarg_parse_one_optional'>, '__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 0x7ff8ee1ac410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_optional'>, '__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 0x7ff8ee1ac9b0> 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 0x7ff8ee1ac9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_optional'>, '__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_pyarg_parse_one_optional'>, '__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 0x7ff8ee1ac960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_optional'>, '__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 0x7ff8ee1acf50> 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 0x7ff8ee1acf50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_optional'>, '__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_pyarg_parse_one_optional'>, '__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_pyarg_parse_one_optional'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_one_optional'> 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_pyarg_parse_one_optional at 0x7ff8ef348bd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee179910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee179e50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_one_optional(): """ An object corresponding to a format specifier after a `|` in the argument format string is optional and may be passed or not. """ twoopt = self.import_parser( ''' PyObject *a; PyObject *b = NULL; if (!PyArg_ParseTuple(args, "O|O", &a, &b)) { return NULL; } if (b) Py_INCREF(b); else b = PyLong_FromLong(42); /* return an owned reference */ return b; ''') assert twoopt(1) == 42 assert twoopt(1, 2) == 2 raises(TypeError, twoopt, 1, 2, 3) try: test_pyarg_parse_one_optional() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestGetargs.test_pyarg_parse_string_py_buffer _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3f27d0>, 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_pyarg_parse_string_py_buffer'>,...icall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_string_py_buffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_string_py_buffer'>,...icall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_string_py_buffer'>} 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_pyarg_parse_string_py_buffer'>,...icall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_string_py_buffer'>} 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_pyarg_parse_string_py_buffer'>, '__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 0x7ff8ee0fe730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._py_buffer'>, '__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 0x7ff8ee0fe910> 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 0x7ff8ee0fe910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._py_buffer'>, '__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_pyarg_parse_string_py_buffer'>, '__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 0x7ff8ee0fea00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._py_buffer'>, '__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 0x7ff8ee0feaa0> 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 0x7ff8ee0feaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._py_buffer'>, '__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_pyarg_parse_string_py_buffer'>, '__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_pyarg_parse_string_py_buffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_string_py_buffer'> 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_pyarg_parse_string_py_buffer at 0x7ff8ef348c50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee191410>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee195d90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_string_py_buffer(): """ The `s*` format specifier can be used to parse a str into a Py_buffer structure containing a pointer to the string data and the length of the string data. """ pybuffer = self.import_parser( ''' Py_buffer buf; PyObject *result; if (!PyArg_ParseTuple(args, "s*", &buf)) { return NULL; } result = PyBytes_FromStringAndSize(buf.buf, buf.len); PyBuffer_Release(&buf); return result; ''') assert b'foo\0bar\0baz' == pybuffer(b'foo\0bar\0baz') #return # XXX? assert b'foo\0bar\0baz' == pybuffer(bytearray(b'foo\0bar\0baz')) try: test_pyarg_parse_string_py_buffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestGetargs.test_pyarg_parse_string_fails _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee18a950>, 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_pyarg_parse_string_fails'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_string_fails'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_string_fails'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_string_fails'>} 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_pyarg_parse_string_fails'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_string_fails'>} 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_pyarg_parse_string_fails'>, '__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 0x7ff8ee1775f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ring_fails'>, '__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 0x7ff8ee294320> 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 0x7ff8ee294320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ring_fails'>, '__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_pyarg_parse_string_fails'>, '__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 0x7ff8ee297370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ring_fails'>, '__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 0x7ff8ee172be0> 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 0x7ff8ee172be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ring_fails'>, '__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_pyarg_parse_string_fails'>, '__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_pyarg_parse_string_fails'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_string_fails'> 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_pyarg_parse_string_fails at 0x7ff8ef348cd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee179e50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee167450> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_string_fails(): """ Test the failing case of PyArg_ParseTuple(): it must not keep a reference on the PyObject passed in. """ pybuffer = self.import_parser( ''' Py_buffer buf1, buf2, buf3; if (!PyArg_ParseTuple(args, "s*s*s*", &buf1, &buf2, &buf3)) { return NULL; } Py_FatalError("should not get there"); return NULL; ''') freed = [] class freestring(bytes): def __del__(self): freed.append('x') raises(TypeError, pybuffer, freestring(b"string"), freestring(b"other string"), 42) self.debug_collect() # gc.collect() is not enough in this test: # we need to check and free the PyObject # linked to the freestring object as well assert freed == ['x', 'x'] try: test_pyarg_parse_string_fails() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________ AppTestGetargs.test_pyarg_parse_charbuf_and_length ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3f27d0>, 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_pyarg_parse_charbuf_and_length'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_charbuf_and_length'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_charbuf_and_length'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_charbuf_and_length'>} 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_pyarg_parse_charbuf_and_length'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_charbuf_and_length'>} 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_pyarg_parse_charbuf_and_length'>, '__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 0x7ff8ee1007d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...and_length'>, '__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 0x7ff8ee100500> 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 0x7ff8ee100500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...and_length'>, '__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_pyarg_parse_charbuf_and_length'>, '__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 0x7ff8ee1008c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...and_length'>, '__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 0x7ff8ee100550> 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 0x7ff8ee100550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...and_length'>, '__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_pyarg_parse_charbuf_and_length'>, '__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_pyarg_parse_charbuf_and_length'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_charbuf_and_length'> 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_pyarg_parse_charbuf_and_length at 0x7ff8ef348d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee179d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee150890> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_charbuf_and_length(): """ The `s#` format specifier can be used to parse a read-only 8-bit character buffer into a char* and int giving its length in bytes. """ charbuf = self.import_parser( ''' char *buf; int len; if (!PyArg_ParseTuple(args, "s#", &buf, &len)) { return NULL; } return PyBytes_FromStringAndSize(buf, len); ''', PY_SSIZE_T_CLEAN=True) raises(TypeError, "charbuf(10)") try: test_pyarg_parse_charbuf_and_length() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestGetargs.test_pyarg_parse_with_py_ssize_t ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2dfcd0>, 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_pyarg_parse_with_py_ssize_t'>, ...ticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t'>, ...ticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t'>} 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_pyarg_parse_with_py_ssize_t'>, ...ticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t'>} 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_pyarg_parse_with_py_ssize_t'>, '__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 0x7ff8ee11f460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...py_ssize_t'>, '__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 0x7ff8ee11f550> 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 0x7ff8ee11f550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...py_ssize_t'>, '__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_pyarg_parse_with_py_ssize_t'>, '__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 0x7ff8ee11f5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...py_ssize_t'>, '__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 0x7ff8ee11f6e0> 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 0x7ff8ee11f6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...py_ssize_t'>, '__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_pyarg_parse_with_py_ssize_t'>, '__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_pyarg_parse_with_py_ssize_t'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_with_py_ssize_t'> 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_pyarg_parse_with_py_ssize_t at 0x7ff8ef348dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee167f10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee167650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_with_py_ssize_t(): charbuf = self.import_parser( ''' char *buf; Py_ssize_t y = -1; if (!PyArg_ParseTuple(args, "s#", &buf, &y)) { return NULL; } return PyLong_FromSsize_t(y); ''', PY_SSIZE_T_CLEAN=True) assert charbuf(b'12345') == 5 try: test_pyarg_parse_with_py_ssize_t() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________ AppTestGetargs.test_pyarg_parse_with_py_ssize_t_bytes _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3daed0>, 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_pyarg_parse_with_py_ssize_t_byt...__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t_bytes'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t_byt...__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t_bytes'>} 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_pyarg_parse_with_py_ssize_t_byt...__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyarg_parse_with_py_ssize_t_bytes'>} 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_pyarg_parse_with_py_ssize_t_bytes'>, '__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 0x7ff8ee18be10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ze_t_bytes'>, '__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 0x7ff8ee18bd20> 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 0x7ff8ee18bd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ze_t_bytes'>, '__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_pyarg_parse_with_py_ssize_t_bytes'>, '__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 0x7ff8ee18bc30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ze_t_bytes'>, '__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 0x7ff8ee124e60> 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 0x7ff8ee124e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ze_t_bytes'>, '__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_pyarg_parse_with_py_ssize_t_bytes'>, '__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_pyarg_parse_with_py_ssize_t_bytes'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyarg_parse_with_py_ssize_t_bytes'> 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_pyarg_parse_with_py_ssize_t_bytes at 0x7ff8ef348e50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee1951d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee150590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyarg_parse_with_py_ssize_t_bytes(): charbuf = self.import_parser( ''' char *buf; Py_ssize_t len = -1; if (!PyArg_ParseTuple(args, "y#", &buf, &len)) { return NULL; } return PyBytes_FromStringAndSize(buf, len); ''', PY_SSIZE_T_CLEAN=True) assert type(charbuf(b'12345')) is bytes assert charbuf(b'12345') == b'12345' try: test_pyarg_parse_with_py_ssize_t_bytes() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestGetargs.test_getargs_keywords _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2dfcd0>, 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_getargs_keywords'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getargs_keywords'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getargs_keywords'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getargs_keywords'>} 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_getargs_keywords'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getargs_keywords'>} 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_getargs_keywords'>, '__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 0x7ff8ee1204b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_keywords'>, '__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 0x7ff8ee120690> 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 0x7ff8ee120690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_keywords'>, '__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_getargs_keywords'>, '__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 0x7ff8ee120780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_keywords'>, '__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 0x7ff8ee120820> 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 0x7ff8ee120820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...s_keywords'>, '__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_getargs_keywords'>, '__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_getargs_keywords'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getargs_keywords'> 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_getargs_keywords at 0x7ff8ef348ed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee150910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1674d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getargs_keywords(): # taken from lib-python/3/test_getargs2.py module = self.import_extension('foo', [ ("getargs_keywords", "METH_KEYWORDS | METH_VARARGS", ''' static char *keywords[] = {"arg1","arg2","arg3","arg4","arg5", NULL}; static char *fmt="(ii)i|(i(ii))(iii)i"; int int_args[10]={-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords, &int_args[0], &int_args[1], &int_args[2], &int_args[3], &int_args[4], &int_args[5], &int_args[6], &int_args[7], &int_args[8], &int_args[9])) return NULL; return Py_BuildValue("iiiiiiiiii", int_args[0], int_args[1], int_args[2], int_args[3], int_args[4], int_args[5], int_args[6], int_args[7], int_args[8], int_args[9] ); ''')]) raises(TypeError, module.getargs_keywords, (1,2), 3, (4,(5,6)), (7,8,9), **{'\uDC80': 10}) try: test_getargs_keywords() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________________ AppTestGetargs.test_y _____________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee18a950>, 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_y'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_y'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_y'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_y'>} 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_y'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_y'>} 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_y'>, '__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 0x7ff8ee0f91e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_y'>, '__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 0x7ff8ee0f99b0> 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 0x7ff8ee0f99b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_y'>, '__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_y'>, '__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 0x7ff8ee0f9960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_y'>, '__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 0x7ff8ee124e60> 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 0x7ff8ee124e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_y'>, '__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_y'>, '__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_y'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_y'> 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_y at 0x7ff8ef348f50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee195490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee167390> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_y(): module = self.import_extension('foo', [ ("getargs_y_star", "METH_VARARGS", """ Py_buffer buffer; PyObject *bytes; if (!PyArg_ParseTuple(args, "y*", &buffer)) return NULL; bytes = PyBytes_FromStringAndSize(buffer.buf, buffer.len); PyBuffer_Release(&buffer); return bytes; """), ("getargs_y", "METH_VARARGS", """ char *str; if (!PyArg_ParseTuple(args, "y", &str)) return NULL; return PyBytes_FromString(str); """), ]) NONCONTIG_WRITABLE = memoryview(bytearray(b'noncontig'))[::-2] NONCONTIG_READONLY = memoryview(b'noncontig')[::-2] with raises(BufferError): module.getargs_y_star(NONCONTIG_WRITABLE) with raises(BufferError): module.getargs_y_star(NONCONTIG_READONLY) assert module.getargs_y(b'bytes') == b'bytes' with raises(TypeError): module.getargs_y(memoryview(b'memoryview')) with raises(TypeError): module.getargs_y(bytearray(b'memoryview')) try: test_y() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________________ AppTestGetargs.test_d _____________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee23c350>, 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_d'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_d'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_d'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_d'>} 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_d'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_d'>} 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_d'>, '__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 0x7ff8ee05c6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_d'>, '__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 0x7ff8ee05ca50> 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 0x7ff8ee05ca50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_d'>, '__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_d'>, '__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 0x7ff8ee05cb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_d'>, '__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 0x7ff8ee05cbe0> 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 0x7ff8ee05cbe0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...od 'test_d'>, '__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_d'>, '__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_d'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_d'> 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_d at 0x7ff8ef346050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee2a3590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2a3d90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_d(): module = self.import_extension('foo', [ ("getargs_d", "METH_VARARGS", """ double d; if (!PyArg_ParseTuple(args, "d", &d)) return NULL; return PyFloat_FromDouble(d); """), ]) class FloatSubclass2(float): def __float__(self): return 4.25 # float subclass value overrides __float__ in PyFloat_AsDouble assert module.getargs_d(FloatSubclass2(7.5)) == 7.5 try: test_d() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestGetargs.test_d_index __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee20fed0>, 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_d_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_d_index'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_d_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_d_index'>} 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_d_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_d_index'>} 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_d_index'>, '__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 0x7ff8ee058690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_d_index'>, '__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 0x7ff8ee058780> 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 0x7ff8ee058780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_d_index'>, '__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_d_index'>, '__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 0x7ff8ee0586e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_d_index'>, '__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 0x7ff8ee058820> 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 0x7ff8ee058820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_d_index'>, '__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_d_index'>, '__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_d_index'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_d_index'> 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_d_index at 0x7ff8ef3460d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee195e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee0e3790> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_d_index(): # Objects implementing __index__ should be accepted by the 'd' format # via the __float__ -> __index__ coercion chain. module = self.import_extension('foo', [ ("getargs_d", "METH_VARARGS", """ double d; if (!PyArg_ParseTuple(args, "d", &d)) return NULL; return PyFloat_FromDouble(d); """), ]) class Index: def __index__(self): return 99 assert module.getargs_d(Index()) == 99.0 try: test_d_index() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestGetargs.test_f_index __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee23c350>, 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_f_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_f_index'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_f_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_f_index'>} 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_f_index'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_f_index'>} 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_f_index'>, '__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 0x7ff8ee1a9370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_f_index'>, '__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 0x7ff8ef347500> 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 0x7ff8ef347500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_f_index'>, '__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_f_index'>, '__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 0x7ff8ee05ca50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_f_index'>, '__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 0x7ff8ee05c870> 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 0x7ff8ee05c870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_f_index'>, '__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_f_index'>, '__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_f_index'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_f_index'> 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_f_index at 0x7ff8ef346150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee1132d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee113450> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_f_index(): # Objects implementing __index__ should be accepted by the 'f' format. module = self.import_extension('foo', [ ("getargs_f", "METH_VARARGS", """ float f; if (!PyArg_ParseTuple(args, "f", &f)) return NULL; return PyFloat_FromDouble((double)f); """), ]) class Index: def __index__(self): return 99 assert module.getargs_f(Index()) == 99.0 try: test_f_index() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestGetargs.test_nested_tuple_es ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3f27d0>, 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_nested_tuple_es'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nested_tuple_es'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_nested_tuple_es'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nested_tuple_es'>} 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_nested_tuple_es'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nested_tuple_es'>} 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_nested_tuple_es'>, '__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 0x7ff8ee0765a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_tuple_es'>, '__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 0x7ff8ee076690> 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 0x7ff8ee076690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_tuple_es'>, '__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_nested_tuple_es'>, '__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 0x7ff8ee076730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_tuple_es'>, '__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 0x7ff8ee076820> 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 0x7ff8ee076820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_tuple_es'>, '__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_nested_tuple_es'>, '__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_nested_tuple_es'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_nested_tuple_es'> 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_nested_tuple_es at 0x7ff8ef3461d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestGetargs.w_compile_module of <pypy.module.cpyext.test.test_getargs.AppTestGetar...TestGetargs.w_import_extension of <pypy.module.cpyext.test.test_getargs.AppTestGetargs object at 0x7ff8ee0c6910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee0c6290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_import_parser(self, implementation, argstyle='METH_VARARGS', PY_SSIZE_T_CLEAN=False): mod = self.import_extension( 'modname', [('funcname', argstyle, implementation)], PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) return mod.funcname type(self).import_parser = w_import_parser def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_nested_tuple_es(): # 'es' and 'et' are two-character format codes; inside a nested tuple # '(es)' the 'e' prefix must not be counted as a separate slot. module = self.import_extension('foo', [ ("getargs_nested_es", "METH_VARARGS", """ const char *encoding = ""; char *buf = NULL; if (!PyArg_ParseTuple(args, "(es)", encoding, &buf)) return NULL; PyObject *result = PyUnicode_FromString(buf); PyMem_Free(buf); return result; """), ]) # '(es)' expects a 1-element tuple; passing a 1-element tuple with # empty encoding should raise LookupError, not TypeError about length. raises(LookupError, module.getargs_nested_es, ('a',)) # passing a 0-element tuple should raise TypeError about length 1 vs 0 exc = raises(TypeError, module.getargs_nested_es, ()) assert "length 1" in str(exc.value) assert "not 0" in str(exc.value) try: test_nested_tuple_es() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestImportLogic.test_import_logic _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2743d0>, 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_import_logic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_import_logic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_import_logic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_import_logic'>} 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_import_logic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_import_logic'>} 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_import_logic'>, '__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 0x7ff8ee076f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_logic'>, '__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 0x7ff8ee13cb40> 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 0x7ff8ee13cb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_logic'>, '__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_import_logic'>, '__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 0x7ff8ee13c780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_logic'>, '__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 0x7ff8ee2c00a0> 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 0x7ff8ee2c00a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_logic'>, '__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_import_logic'>, '__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_import_logic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_import_logic'> 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_import_logic at 0x7ff8ef3626d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestImportLogic.w_compile_module of <pypy.module.cpyext.test.test_import.AppTestIm...ortLogic.w_import_extension of <pypy.module.cpyext.test.test_import.AppTestImportLogic object at 0x7ff8ee2a3ed0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2a3710> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_import_logic(): import sys, os path = self.compile_module('test_import_module', source_files=[os.path.join(self.here, 'test_import_module.c')]) sys.path.append(os.path.dirname(path)) import test_import_module assert test_import_module.TEST is None try: test_import_logic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestImportLogic.test_getmodule _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2dfcd0>, 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_getmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getmodule'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getmodule'>} 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_getmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getmodule'>} 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_getmodule'>, '__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 0x7ff8ee023780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getmodule'>, '__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 0x7ff8ee023a00> 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 0x7ff8ee023a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getmodule'>, '__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_getmodule'>, '__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 0x7ff8ee023af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getmodule'>, '__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 0x7ff8ee023b90> 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 0x7ff8ee023b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getmodule'>, '__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_getmodule'>, '__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_getmodule'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getmodule'> 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_getmodule at 0x7ff8ef362750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestImportLogic.w_compile_module of <pypy.module.cpyext.test.test_import.AppTestIm...ortLogic.w_import_extension of <pypy.module.cpyext.test.test_import.AppTestImportLogic object at 0x7ff8ee04ea10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee298a90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getmodule(): import sys module = self.import_extension('foo', [ ("getmodule", "METH_O", ''' PyObject *mod = PyImport_GetModule(args); if (mod == NULL) { Py_RETURN_NONE; } return mod; ''')]) _sys = module.getmodule('sys') assert sys is _sys assert module.getmodule('not_in_sys_modules') is None try: test_getmodule() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________ AppTestIterator.test_noniterable_object_with_mapping_interface ________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee3daed0>, 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_noniterable_object_with_mapping...ultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_noniterable_object_with_mapping_interface'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_noniterable_object_with_mapping...ultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_noniterable_object_with_mapping_interface'>} 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_noniterable_object_with_mapping...ultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_noniterable_object_with_mapping_interface'>} 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_noniterable_object_with_mapping_interface'>, '__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 0x7ff8ee014500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interface'>, '__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 0x7ff8ee014460> 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 0x7ff8ee014460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interface'>, '__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_noniterable_object_with_mapping_interface'>, '__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 0x7ff8ee0145a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interface'>, '__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 0x7ff8ee014640> 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 0x7ff8ee014640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interface'>, '__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_noniterable_object_with_mapping_interface'>, '__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_noniterable_object_with_mapping_interface'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_noniterable_object_with_mapping_interface'> 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_noniterable_object_with_mapping_interface at 0x7ff8ef3672d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestIterator.w_compile_module of <pypy.module.cpyext.test.test_iterator.AppTestIte...tIterator.w_import_extension of <pypy.module.cpyext.test.test_iterator.AppTestIterator object at 0x7ff8ee113510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee113250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_noniterable_object_with_mapping_interface(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", ''' PyObject *obj; obj = PyObject_New(PyObject, &Foo_Type); return obj; ''' ), ("get_dictproxy", "METH_O", ''' return PyDictProxy_New(args); ''' ), ("check", "METH_O", ''' return PyLong_FromLong( PySequence_Check(args) + PyMapping_Check(args) * 2); ''') ], prologue = ''' static PyObject * mp_subscript(PyObject *self, PyObject *key) { return PyLong_FromLong(42); } static Py_ssize_t mp_length(PyObject *self) { return 2; } PyMappingMethods tp_as_mapping; static PyTypeObject Foo_Type = { PyVarObject_HEAD_INIT(NULL, 0) "foo.foo", }; ''', more_init = ''' Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; Foo_Type.tp_as_mapping = &tp_as_mapping; tp_as_mapping.mp_length = mp_length; tp_as_mapping.mp_subscript = mp_subscript; if (PyType_Ready(&Foo_Type) < 0) INITERROR; ''') obj = module.test() assert obj["hi there"] == 42 assert len(obj) == 2 assert not hasattr(obj, "__iter__") e = raises(TypeError, iter, obj) assert str(e.value).endswith("object is not iterable") # assert module.check(obj) == 2 # make sure dictionaries return false for PySequence_Check assert module.check({'a': 1}) == 2 obj = module.get_dictproxy({'a': 10}) assert module.check(obj) == 2 try: test_noniterable_object_with_mapping_interface() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestIterator.test_iterable_nonmapping_object ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee2dfcd0>, 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_iterable_nonmapping_object'>, '...lticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iterable_nonmapping_object'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_iterable_nonmapping_object'>, '...lticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iterable_nonmapping_object'>} 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_iterable_nonmapping_object'>, '...lticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_iterable_nonmapping_object'>} 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_iterable_nonmapping_object'>, '__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 0x7ff8ee0edaf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ing_object'>, '__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 0x7ff8ee0edf50> 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 0x7ff8ee0edf50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ing_object'>, '__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_iterable_nonmapping_object'>, '__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 0x7ff8ee0ed1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ing_object'>, '__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 0x7ff8ee0edf00> 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 0x7ff8ee0edf00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ing_object'>, '__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_iterable_nonmapping_object'>, '__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_iterable_nonmapping_object'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_iterable_nonmapping_object'> 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_iterable_nonmapping_object at 0x7ff8ef367350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestIterator.w_compile_module of <pypy.module.cpyext.test.test_iterator.AppTestIte...tIterator.w_import_extension of <pypy.module.cpyext.test.test_iterator.AppTestIterator object at 0x7ff8ee111d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee111ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_iterable_nonmapping_object(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", ''' PyObject *obj; obj = PyObject_New(PyObject, &Foo_Type); return obj; '''), ("check", "METH_O", ''' return PyLong_FromLong( PySequence_Check(args) + PyMapping_Check(args) * 2); ''') ], prologue=''' static PyObject * sq_item(PyObject *self, Py_ssize_t size) { return PyLong_FromLong(42); } static Py_ssize_t sq_length(PyObject *self) { return 2; } static PyObject * sq_repeat(PyObject *self, Py_ssize_t n) { return PyLong_FromLong(144); } static PyObject * sq_inplace_repeat(PyObject *self, Py_ssize_t n) { //fprintf(stdout, "in sq_inplace_repeat, n=%ld\\n", n); Py_INCREF(self); return self; } PySequenceMethods tp_as_sequence; static PyTypeObject Foo_Type = { PyVarObject_HEAD_INIT(NULL, 0) "foo.foo", }; ''', more_init=''' Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; Foo_Type.tp_as_sequence = &tp_as_sequence; tp_as_sequence.sq_length = sq_length; tp_as_sequence.sq_item = sq_item; tp_as_sequence.sq_repeat = sq_repeat; tp_as_sequence.sq_inplace_repeat = sq_inplace_repeat; if (PyType_Ready(&Foo_Type) < 0) INITERROR; ''') obj = module.test() assert obj[1] == 42 assert len(obj) == 2 assert not hasattr(obj, "__iter__") it = iter(obj) assert next(it) == 42 assert next(it) == 42 # assert module.check(obj) == 1 assert obj * 3 == 144 obj *= 3 assert obj[1] == 42 try: test_iterable_nonmapping_object() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestListObject.test_basic_listobject ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1dd750>, 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_basic_listobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic_listobject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_basic_listobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic_listobject'>} 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_basic_listobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic_listobject'>} 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_basic_listobject'>, '__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 0x7ff8ee023640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...listobject'>, '__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 0x7ff8ee023730> 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 0x7ff8ee023730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...listobject'>, '__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_basic_listobject'>, '__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 0x7ff8ee023460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...listobject'>, '__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 0x7ff8ee023370> 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 0x7ff8ee023370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...listobject'>, '__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_basic_listobject'>, '__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_basic_listobject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_basic_listobject'> 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_basic_listobject at 0x7ff8ef376d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestListObject.w_compile_module of <pypy.module.cpyext.test.test_listobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_listobject.AppTestListObject object at 0x7ff8ee111610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee07a9d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_basic_listobject(): import sys module = self.import_extension('foo', [ ("newlist", "METH_NOARGS", """ PyObject *lst = PyList_New(3); PyList_SetItem(lst, 0, PyLong_FromLong(3)); PyList_SetItem(lst, 2, PyLong_FromLong(1000)); PyList_SetItem(lst, 1, PyLong_FromLong(-5)); return lst; """ ), ("setlistitem", "METH_VARARGS", """ PyObject *l = PyTuple_GetItem(args, 0); int index = PyLong_AsLong(PyTuple_GetItem(args, 1)); Py_INCREF(Py_None); if (PyList_SetItem(l, index, Py_None) < 0) return NULL; Py_INCREF(Py_None); return Py_None; """ ), ("appendlist", "METH_VARARGS", """ PyObject *l = PyTuple_GetItem(args, 0); PyList_Append(l, PyTuple_GetItem(args, 1)); Py_RETURN_NONE; """ ), ("setslice", "METH_VARARGS", """ PyObject *l = PyTuple_GetItem(args, 0); PyObject *seq = PyTuple_GetItem(args, 1); if (seq == Py_None) seq = NULL; if (PyList_SetSlice(l, 1, 4, seq) < 0) return NULL; Py_RETURN_NONE; """ ), ('test_tp_as_', "METH_NOARGS", ''' PyObject *l = PyList_New(3); int ok = l->ob_type->tp_as_sequence != NULL; /* 1 */ ok += 2 * (l->ob_type->tp_as_number == NULL); /* 2 */ Py_DECREF(l); return PyLong_FromLong(ok); /* should be 3 */ ''' ), ]) l = module.newlist() assert l == [3, -5, 1000] module.setlistitem(l, 0) assert l[0] is None class L(list): def __setitem__(self): self.append("XYZ") l = L([1]) module.setlistitem(l, 0) assert len(l) == 1 raises(SystemError, module.setlistitem, (1, 2, 3), 0) l = [] module.appendlist(l, 14) assert len(l) == 1 assert l[0] == 14 l = list(range(6)) module.setslice(l, ['a']) assert l == [0, 'a', 4, 5] l = list(range(6)) module.setslice(l, None) assert l == [0, 4, 5] l = [1, 2, 3] module.setlistitem(l,0) assert l == [None, 2, 3] # tp_as_sequence should be filled, but tp_as_number should be NULL assert module.test_tp_as_() == 3 l = module.newlist() p = l.pop() assert p == 1000 p = l.pop(0) assert p == 3 assert l == [-5] try: test_basic_listobject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestListObject.test_list_spec _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee255750>, 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_list_spec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_list_spec'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_list_spec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_list_spec'>} 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_list_spec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_list_spec'>} 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_list_spec'>, '__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 0x7ff8ee0b36e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_spec'>, '__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 0x7ff8ee0b3960> 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 0x7ff8ee0b3960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_spec'>, '__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_list_spec'>, '__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 0x7ff8ee0b3a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_spec'>, '__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 0x7ff8ee0b3af0> 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 0x7ff8ee0b3af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._list_spec'>, '__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_list_spec'>, '__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_list_spec'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_list_spec'> 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_list_spec at 0x7ff8ef376dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestListObject.w_compile_module of <pypy.module.cpyext.test.test_listobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_listobject.AppTestListObject object at 0x7ff8ee1112d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee111350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_list_spec(): module = self.import_extension("foo", [ ("setslice_slot", "METH_VARARGS", """ PyObject *l = PyTuple_GetItem(args, 0); PyObject *seq = PyTuple_GetItem(args, 1); PyMappingMethods* mp = Py_TYPE(l)->tp_as_mapping; if (mp && mp->mp_ass_subscript) { if (seq == Py_None) seq = NULL; PyObject *py_slice, *py_start, *py_stop; py_start = PyLong_FromSsize_t(1); py_stop = PyLong_FromSsize_t(4); py_slice = PySlice_New(py_start, py_stop, Py_None); int result = mp->mp_ass_subscript(l, py_slice, seq); Py_DECREF(py_start); Py_DECREF(py_stop); Py_DECREF(py_slice); if (result < 0) return NULL; } else { PyErr_Format(PyExc_TypeError, "slice assignment not supported"); return NULL; } Py_RETURN_NONE; """), ("get_sublist", "METH_NOARGS", """ PyType_Slot slots[] = { {0, 0}, }; PyType_Spec sublist_spec = { "sublist", 0, 0, Py_TPFLAGS_DEFAULT, slots, }; PyObject *t1 = PyTuple_Pack(1, (PyObject *)(&PyList_Type)); PyObject *ret = PyType_FromSpecWithBases(&sublist_spec, t1); Py_DECREF(t1); return ret; """)]) sublist = module.get_sublist() l = sublist(range(6)) module.setslice_slot(l, ['a']) assert l == [0, 'a', 4, 5] try: test_list_spec() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestListObject.test_list_macros ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1800d0>, 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_list_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_list_macros'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_list_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_list_macros'>} 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_list_macros'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_list_macros'>} 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_list_macros'>, '__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 0x7ff8ee28feb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ist_macros'>, '__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 0x7ff8ee0b3190> 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 0x7ff8ee0b3190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ist_macros'>, '__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_list_macros'>, '__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 0x7ff8ee0e04b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ist_macros'>, '__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 0x7ff8ee0e0e60> 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 0x7ff8ee0e0e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ist_macros'>, '__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_list_macros'>, '__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_list_macros'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_list_macros'> 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_list_macros at 0x7ff8ef376e50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestListObject.w_compile_module of <pypy.module.cpyext.test.test_listobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_listobject.AppTestListObject object at 0x7ff8ee07a5d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee195110> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_list_macros(): """The PyList_* macros cast, and calls expecting that build.""" module = self.import_extension('foo', [ ("test_macro_invocations", "METH_O", """ PyObject* o = PyList_New(2); PyListObject* l = (PyListObject*)o; Py_INCREF(args); Py_INCREF(args); PyList_SET_ITEM(o, 0, args); PyList_SET_ITEM(l, 1, args); if(PyList_GET_ITEM(o, 0) != PyList_GET_ITEM(l, 1)) { PyErr_SetString(PyExc_AssertionError, "PyList_GET_ITEM error"); return NULL; } if(PyList_GET_SIZE(o) != PyList_GET_SIZE(l)) { PyErr_SetString(PyExc_AssertionError, "PyList_GET_SIZE error"); return NULL; } return o; """ ) ]) s = 'abcdef' x = module.test_macro_invocations(s) assert x[0] is x[1] is s try: test_list_macros() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestListObject.test_get_item_macro _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1dd750>, 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_get_item_macro'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_item_macro'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_get_item_macro'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_item_macro'>} 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_get_item_macro'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_item_macro'>} 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_get_item_macro'>, '__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 0x7ff8ee0b14b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_macro'>, '__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 0x7ff8ee0b16e0> 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 0x7ff8ee0b16e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_macro'>, '__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_get_item_macro'>, '__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 0x7ff8ee0b1730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_macro'>, '__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 0x7ff8ee0b1820> 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 0x7ff8ee0b1820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...item_macro'>, '__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_get_item_macro'>, '__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_get_item_macro'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_get_item_macro'> 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_get_item_macro at 0x7ff8ef376ed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestListObject.w_compile_module of <pypy.module.cpyext.test.test_listobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_listobject.AppTestListObject object at 0x7ff8ee025d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee025dd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_get_item_macro(): module = self.import_extension('foo', [ ("test_get_item", "METH_NOARGS", """ PyObject* o, *o2, *o3; o = PyList_New(1); o2 = PyBytes_FromString("test_get_item0"); Py_INCREF(o2); PyList_SET_ITEM(o, 0, o2); o3 = PyList_GET_ITEM(o, 0); Py_INCREF(o3); Py_DECREF(o); Py_DECREF(o2); return o3; """)]) assert module.test_get_item() == b'test_get_item0' try: test_get_item_macro() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestListObject.test_item_refcounts _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee149bd0>, 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_item_refcounts'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_item_refcounts'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_item_refcounts'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_item_refcounts'>} 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_item_refcounts'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_item_refcounts'>} 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_item_refcounts'>, '__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 0x7ff8ee0a0be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._refcounts'>, '__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 0x7ff8ee05c2d0> 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 0x7ff8ee05c2d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._refcounts'>, '__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_item_refcounts'>, '__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 0x7ff8ee05c4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._refcounts'>, '__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 0x7ff8ee065aa0> 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 0x7ff8ee065aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._refcounts'>, '__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_item_refcounts'>, '__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_item_refcounts'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_item_refcounts'> 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_item_refcounts at 0x7ff8ef376f50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestListObject.w_compile_module of <pypy.module.cpyext.test.test_listobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_listobject.AppTestListObject object at 0x7ff8ee03cb50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee03c8d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_item_refcounts(): """PyList_SET_ITEM leaks a reference to the target.""" module = self.import_extension('foo', [ ("test_refcount_diff", "METH_VARARGS", """ /* test that the refcount differences for functions * are correct. diff1 - expected refcount diff for i1, * diff2 - expected refcount diff for i2 */ #define CHECKCOUNT(diff1, diff2, action) \ new_count1 = Py_REFCNT(i1); \ new_count2 = Py_REFCNT(i2); \ diff = new_count1 - old_count1; \ if (diff != diff1) {\ sprintf(errbuffer, action \ " i1 expected diff of %ld got %ld", (long)diff1, (long)diff); \ PyErr_SetString(PyExc_AssertionError, errbuffer); \ return NULL; } \ diff = new_count2 - old_count2; \ if (diff != diff2) {\ sprintf(errbuffer, action \ " i2 expected diff of %ld got %ld", (long)diff2, (long)diff); \ PyErr_SetString(PyExc_AssertionError, errbuffer); \ return NULL; } \ old_count1 = new_count1; \ old_count2 = new_count2; PyObject* tmp, *o = PyList_New(0); char errbuffer[1024]; PyObject* i1 = PyTuple_GetItem(args, 0); PyObject* i2 = PyTuple_GetItem(args, 1); Py_ssize_t old_count1, new_count1; Py_ssize_t old_count2, new_count2; Py_ssize_t diff; int ret; old_count1 = Py_REFCNT(i1); old_count2 = Py_REFCNT(i2); ret = PyList_Append(o, i1); if (ret != 0) return NULL; /* check the result of Append(), and also force the list to use the CPyListStrategy now */ if (PyList_GET_ITEM(o, 0) != i1) { PyErr_SetString(PyExc_AssertionError, "Append() error?"); return NULL; } CHECKCOUNT(1, 0, "PyList_Append"); Py_INCREF(i2); /* for PyList_SET_ITEM */ CHECKCOUNT(0, 1, "Py_INCREF"); PyList_SET_ITEM(o, 0, i2); CHECKCOUNT(0, 0, "PyList_SET_ITEM"); tmp = PyList_GET_ITEM(o, 0); if (tmp != i2) { PyErr_SetString(PyExc_AssertionError, "SetItem() error?"); return NULL; } CHECKCOUNT(0, 0, "PyList_GET_ITEM"); PyList_SetItem(o, 0, i1); CHECKCOUNT(0, -1, "PyList_Set_Item"); PyList_GetItem(o, 0); CHECKCOUNT(0, 0, "PyList_Get_Item"); Py_DECREF(o); #ifndef PYPY_VERSION { // PyPy deletes only at teardown CHECKCOUNT(-1, 0, "Py_DECREF(o)"); } #endif return PyLong_FromSsize_t(0); """)]) assert module.test_refcount_diff(["first"], ["second"]) == 0 try: test_item_refcounts() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestLongObject.test_fromunsignedlong ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1dd050>, 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_fromunsignedlong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunsignedlong'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromunsignedlong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunsignedlong'>} 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_fromunsignedlong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunsignedlong'>} 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_fromunsignedlong'>, '__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 0x7ff8ee073730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...signedlong'>, '__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 0x7ff8ee0737d0> 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 0x7ff8ee0737d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...signedlong'>, '__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_fromunsignedlong'>, '__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 0x7ff8ee073500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...signedlong'>, '__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 0x7ff8ee0730a0> 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 0x7ff8ee0730a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...signedlong'>, '__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_fromunsignedlong'>, '__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_fromunsignedlong'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromunsignedlong'> 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_fromunsignedlong at 0x7ff8ef21fcd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee07a350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee07ac50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromunsignedlong(): module = self.import_extension('foo', [ ("from_unsignedlong", "METH_NOARGS", """ PyObject * obj; obj = PyLong_FromUnsignedLong((unsigned long)-1); if (obj->ob_type != &PyLong_Type) { Py_DECREF(obj); PyErr_SetString(PyExc_ValueError, "PyLong_FromLongLong did not return PyLongObject"); return NULL; } return obj; """), ]) import struct max_ul = struct.unpack_from('L', b'\xff'*8)[0] assert module.from_unsignedlong() == max_ul try: test_fromunsignedlong() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestLongObject.test_fromlonglong ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1807d0>, 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_fromlonglong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromlonglong'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromlonglong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromlonglong'>} 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_fromlonglong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromlonglong'>} 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_fromlonglong'>, '__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 0x7ff8edfa8550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omlonglong'>, '__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 0x7ff8edfa85f0> 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 0x7ff8edfa85f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omlonglong'>, '__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_fromlonglong'>, '__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 0x7ff8edfa86e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omlonglong'>, '__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 0x7ff8edfa8820> 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 0x7ff8edfa8820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...omlonglong'>, '__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_fromlonglong'>, '__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_fromlonglong'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromlonglong'> 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_fromlonglong at 0x7ff8ef21fd50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee2b1a90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee2b1bd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromlonglong(): module = self.import_extension('foo', [ ("from_longlong", "METH_VARARGS", """ int val; PyObject * obj; if (!PyArg_ParseTuple(args, "i", &val)) return NULL; obj = PyLong_FromLongLong((long long)val); if (obj->ob_type != &PyLong_Type) { Py_DECREF(obj); PyErr_SetString(PyExc_ValueError, "PyLong_FromLongLong did not return PyLongObject"); return NULL; } return obj; """), ("from_unsignedlonglong", "METH_VARARGS", """ int val; PyObject * obj; if (!PyArg_ParseTuple(args, "i", &val)) return NULL; obj = PyLong_FromUnsignedLongLong((long long)val); if (obj->ob_type != &PyLong_Type) { Py_DECREF(obj); PyErr_SetString(PyExc_ValueError, "PyLong_FromLongLong did not return PyLongObject"); return NULL; } return obj; """)]) assert module.from_longlong(-1) == -1 assert module.from_longlong(0) == 0 assert module.from_unsignedlonglong(0) == 0 assert module.from_unsignedlonglong(-1) == (1<<64) - 1 try: test_fromlonglong() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestLongObject.test_from_size_t ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1dd050>, 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_from_size_t'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_from_size_t'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_from_size_t'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_from_size_t'>} 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_from_size_t'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_from_size_t'>} 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_from_size_t'>, '__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 0x7ff8ee0b1eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rom_size_t'>, '__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 0x7ff8ee0b1dc0> 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 0x7ff8ee0b1dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rom_size_t'>, '__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_from_size_t'>, '__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 0x7ff8ee0b1e10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rom_size_t'>, '__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 0x7ff8ee08c050> 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 0x7ff8ee08c050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rom_size_t'>, '__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_from_size_t'>, '__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_from_size_t'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_from_size_t'> 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_from_size_t at 0x7ff8ef21fdd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee03c3d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee167510> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_from_size_t(): module = self.import_extension('foo', [ ("from_unsignedlong", "METH_NOARGS", """ return PyLong_FromSize_t((size_t)-1); """)]) import sys assert module.from_unsignedlong() == 2 * sys.maxsize + 1 try: test_from_size_t() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestLongObject.test_from_long _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1807d0>, 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_from_long'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_from_long'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_from_long'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_from_long'>} 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_from_long'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_from_long'>} 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_from_long'>, '__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 0x7ff8edfb45a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._from_long'>, '__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 0x7ff8edfb4640> 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 0x7ff8edfb4640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._from_long'>, '__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_from_long'>, '__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 0x7ff8edfb4730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._from_long'>, '__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 0x7ff8edfb4690> 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 0x7ff8edfb4690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._from_long'>, '__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_from_long'>, '__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_from_long'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_from_long'> 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_from_long at 0x7ff8ef21fe50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee0bfcd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee0bf2d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_from_long(): module = self.import_extension('foo', [ ("asunsignedlong", "METH_O", """ unsigned long n = PyLong_AsUnsignedLong(args); if ((long)n == -1 && PyErr_Occurred()) { return NULL; } return PyLong_FromUnsignedLong(n); """), ("assize_t", "METH_O", """ size_t n = PyLong_AsSize_t(args); if ((long)n == -1 && PyErr_Occurred()) { return NULL; } return PyLong_FromSize_t(n); """), ("asunsignedlonglong", "METH_O", """ unsigned long n = PyLong_AsUnsignedLongLong(args); if ((long)n == -1 && PyErr_Occurred()) { return NULL; } return PyLong_FromUnsignedLongLong(n); """)]) with raises(OverflowError): module.asunsignedlong(-1) with raises(OverflowError): module.asunsignedlonglong(-1) assert module.assize_t(100) == 100 try: test_from_long() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestLongObject.test_fromstring _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee28e4d0>, 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_fromstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromstring'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromstring'>} 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_fromstring'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromstring'>} 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_fromstring'>, '__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 0x7ff8ee0a7230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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 0x7ff8ee0a71e0> 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 0x7ff8ee0a71e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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_fromstring'>, '__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 0x7ff8ee0a70a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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 0x7ff8ee0a7690> 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 0x7ff8ee0a7690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromstring'>, '__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_fromstring'>, '__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_fromstring'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromstring'> 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_fromstring at 0x7ff8ef21fed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee111910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee111950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromstring(): module = self.import_extension('foo', [ ("from_string", "METH_NOARGS", """ return PyLong_FromString("0x1234", NULL, 0); """), ]) assert module.from_string() == 0x1234 try: test_fromstring() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestLongObject.test_frombytearray _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf93850>, 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_frombytearray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frombytearray'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_frombytearray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frombytearray'>} 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_frombytearray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frombytearray'>} 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_frombytearray'>, '__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 0x7ff8edfb6550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mbytearray'>, '__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 0x7ff8edfb67d0> 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 0x7ff8edfb67d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mbytearray'>, '__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_frombytearray'>, '__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 0x7ff8edfb68c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mbytearray'>, '__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 0x7ff8edfb6960> 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 0x7ff8edfb6960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...mbytearray'>, '__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_frombytearray'>, '__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_frombytearray'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_frombytearray'> 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_frombytearray at 0x7ff8ef21ff50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee09b750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee09b590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_frombytearray(): module = self.import_extension('foo', [ ("from_bytearray", "METH_VARARGS", """ int little_endian, is_signed; if (!PyArg_ParseTuple(args, "ii", &little_endian, &is_signed)) return NULL; return _PyLong_FromByteArray((unsigned char*)"\\x9A\\xBC", 2, little_endian, is_signed); """), ]) assert module.from_bytearray(True, False) == 0xBC9A assert module.from_bytearray(True, True) == -0x4366 assert module.from_bytearray(False, False) == 0x9ABC assert module.from_bytearray(False, True) == -0x6544 try: test_frombytearray() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestLongObject.test_frombytearray_2 ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee055e50>, 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_frombytearray_2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frombytearray_2'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_frombytearray_2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frombytearray_2'>} 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_frombytearray_2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frombytearray_2'>} 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_frombytearray_2'>, '__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 0x7ff8ee0eab40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytearray_2'>, '__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 0x7ff8ee0eaa50> 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 0x7ff8ee0eaa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytearray_2'>, '__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_frombytearray_2'>, '__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 0x7ff8ee0eac30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytearray_2'>, '__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 0x7ff8ee0eabe0> 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 0x7ff8ee0eabe0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ytearray_2'>, '__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_frombytearray_2'>, '__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_frombytearray_2'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_frombytearray_2'> 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_frombytearray_2 at 0x7ff8ef21b050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee096c10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee096a90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_frombytearray_2(): module = self.import_extension('foo', [ ("from_bytearray", "METH_VARARGS", """ int little_endian, is_signed; if (!PyArg_ParseTuple(args, "ii", &little_endian, &is_signed)) return NULL; return _PyLong_FromByteArray((unsigned char*)"\\x9A\\xBC\\x41", 3, little_endian, is_signed); """), ]) assert module.from_bytearray(True, False) == 0x41BC9A assert module.from_bytearray(True, True) == 0x41BC9A assert module.from_bytearray(False, False) == 0x9ABC41 assert module.from_bytearray(False, True) == -0x6543BF try: test_frombytearray_2() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestLongObject.test_asbytearray ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee28e1d0>, 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_asbytearray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asbytearray'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_asbytearray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asbytearray'>} 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_asbytearray'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_asbytearray'>} 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_asbytearray'>, '__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 0x7ff8edf745a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sbytearray'>, '__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 0x7ff8edf74820> 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 0x7ff8edf74820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sbytearray'>, '__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_asbytearray'>, '__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 0x7ff8edf74910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sbytearray'>, '__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 0x7ff8edf749b0> 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 0x7ff8edf749b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...sbytearray'>, '__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_asbytearray'>, '__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_asbytearray'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_asbytearray'> 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_asbytearray at 0x7ff8ef21b0d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee09b850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee09bf50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_asbytearray(): module = self.import_extension('foo', [ ("as_bytearray", "METH_VARARGS", """ PyObject *result; PyLongObject *o; int n, little_endian, is_signed; unsigned char *bytes; if (!PyArg_ParseTuple(args, "O!iii", &PyLong_Type, &o, &n, &little_endian, &is_signed)) return NULL; bytes = malloc(n); if (_PyLong_AsByteArray(o, bytes, (size_t)n, little_endian, is_signed) != 0) { free(bytes); return NULL; } result = PyBytes_FromStringAndSize((const char *)bytes, n); free(bytes); return result; """), ]) s = module.as_bytearray(0x41BC9A, 4, True, False) assert s == b"\x9A\xBC\x41\x00" s = module.as_bytearray(0x41BC9A, 4, False, False) assert s == b"\x00\x41\xBC\x9A" s = module.as_bytearray(0x41BC9A, 3, True, False) assert s == b"\x9A\xBC\x41" s = module.as_bytearray(0x41BC9A, 3, True, True) assert s == b"\x9A\xBC\x41" s = module.as_bytearray(0x9876, 2, True, False) assert s == b"\x76\x98" s = module.as_bytearray(0x9876 - 0x10000, 2, True, True) assert s == b"\x76\x98" raises(OverflowError, module.as_bytearray, 0x9876, 2, False, True) raises(OverflowError, module.as_bytearray, -1, 2, True, False) raises(OverflowError, module.as_bytearray, 0x1234567, 3, True, False) try: test_asbytearray() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestLongObject.test_fromunicode ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee055e50>, 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_fromunicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunicode'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromunicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunicode'>} 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_fromunicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunicode'>} 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_fromunicode'>, '__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 0x7ff8edf5b370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...romunicode'>, '__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 0x7ff8edf5b550> 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 0x7ff8edf5b550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...romunicode'>, '__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_fromunicode'>, '__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 0x7ff8edf5b640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...romunicode'>, '__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 0x7ff8edf5b6e0> 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 0x7ff8edf5b6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...romunicode'>, '__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_fromunicode'>, '__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_fromunicode'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromunicode'> 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_fromunicode at 0x7ff8ef21b150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8edf83c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf83710> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromunicode(): module = self.import_extension('foo', [ ("from_unicode", "METH_O", """ _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS Py_UNICODE* u = PyUnicode_AsUnicode(args); _Py_COMP_DIAG_POP return Py_BuildValue("NN", PyLong_FromUnicode(u, 6, 10), PyLong_FromUnicode(u, 6, 16)); """), ]) # A string with arabic digits. 'BAD' is after the 6th character. assert module.from_unicode(u' 1\u0662\u0663\u0664BAD') == (1234, 4660) try: test_fromunicode() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestLongObject.test_fromunicodeobject ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee28e1d0>, 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_fromunicodeobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunicodeobject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromunicodeobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunicodeobject'>} 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_fromunicodeobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromunicodeobject'>} 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_fromunicodeobject'>, '__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 0x7ff8ee01df00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...codeobject'>, '__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 0x7ff8ee0ad320> 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 0x7ff8ee0ad320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...codeobject'>, '__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_fromunicodeobject'>, '__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 0x7ff8ee0ad1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...codeobject'>, '__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 0x7ff8ee0ada50> 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 0x7ff8ee0ada50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...codeobject'>, '__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_fromunicodeobject'>, '__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_fromunicodeobject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromunicodeobject'> 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_fromunicodeobject at 0x7ff8ef21b1d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8ee096710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee09b590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromunicodeobject(): module = self.import_extension('foo', [ ("from_unicodeobject", "METH_O", """ return Py_BuildValue("NN", PyLong_FromUnicodeObject(args, 10), PyLong_FromUnicodeObject(args, 16)); """), ]) # A string with arabic digits. assert (module.from_unicodeobject(u' 1\u0662\u0663\u0664') == (1234, 4660)) try: test_fromunicodeobject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestLongObject.test_aslong _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0f49d0>, 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_aslong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_aslong'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_aslong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_aslong'>} 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_aslong'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_aslong'>} 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_aslong'>, '__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 0x7ff8edf7e5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_aslong'>, '__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 0x7ff8edf7e6e0> 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 0x7ff8edf7e6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_aslong'>, '__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_aslong'>, '__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 0x7ff8edf7e780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_aslong'>, '__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 0x7ff8edf7e870> 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 0x7ff8edf7e870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_aslong'>, '__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_aslong'>, '__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_aslong'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_aslong'> 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_aslong at 0x7ff8ef21b250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8edf83350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf83290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_aslong(): module = self.import_extension('foo', [ ("as_long", "METH_O", """ long n = PyLong_AsLong(args); if (n == -1 && PyErr_Occurred()) { return NULL; } return PyLong_FromLong(n); """), ("as_int", "METH_O", """ int n = _PyLong_AsInt(args); if (n == -1 && PyErr_Occurred()) { return NULL; } return PyLong_FromLong(n); """), ("long_max", "METH_NOARGS", """ return PyLong_FromLong(LONG_MAX); """ ), ("long_min", "METH_NOARGS", """ return PyLong_FromLong(LONG_MIN); """ ), ("int_max", "METH_NOARGS", """ return PyLong_FromLong(INT_MAX); """ ), ("int_min", "METH_NOARGS", """ return PyLong_FromLong(INT_MIN); """ ), ("as_unsignedlongmask", "METH_O", """ unsigned long n = PyLong_AsUnsignedLongMask(args); if (n == (unsigned long)-1 && PyErr_Occurred()) { return NULL; } return PyLong_FromLong(n); """), ]) module.as_long(123) == 123 assert module.as_long(-1) == -1 with raises(TypeError): module.as_long(1.23) == 1 LONG_MAX = module.long_max() LONG_MIN = module.long_min() assert module.as_long(LONG_MAX) == LONG_MAX raises(OverflowError, module.as_long, LONG_MAX+ 1) assert module.as_long(LONG_MIN) == LONG_MIN raises(OverflowError, module.as_long, LONG_MIN - 1) # does not raise module.as_unsignedlongmask(LONG_MAX * 10) class A: def __index__(self): return 42 def __int__(self): return 21 class B(): def __int__(self): return 21 a = A() b = B() assert int(a) == 21 # new for python3.8: first try __index__ assert module.as_long(a) == 42 assert module.as_unsignedlongmask(a) == 42 with raises(TypeError): module.as_long(b) with raises(TypeError): module.as_unsignedlongmask(b) assert module.as_int(123) == 123 assert module.as_int(-1) == -1 with raises(TypeError): module.as_int(1.23) == 1 INT_MAX = module.int_max() INT_MIN = module.int_min() assert module.as_int(INT_MAX) == INT_MAX raises(OverflowError, module.as_int, INT_MAX+ 1) assert module.as_int(INT_MIN) == INT_MIN raises(OverflowError, module.as_int, INT_MIN - 1) assert int(a) == 21 # new for python3.8: first try __index__ assert module.as_int(a) == 42 try: test_aslong() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestLongObject.test_strtol _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf933d0>, 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_strtol'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_strtol'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_strtol'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_strtol'>} 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_strtol'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_strtol'>} 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_strtol'>, '__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 0x7ff8edf1a6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_strtol'>, '__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 0x7ff8edf1a7d0> 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 0x7ff8edf1a7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_strtol'>, '__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_strtol'>, '__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 0x7ff8edf1a870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_strtol'>, '__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 0x7ff8edf1a960> 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 0x7ff8edf1a960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_strtol'>, '__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_strtol'>, '__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_strtol'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_strtol'> 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_strtol at 0x7ff8ef21b2d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8edfab810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edfaba90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_strtol(): module = self.import_extension('foo', [ ("from_str", "METH_NOARGS", """ const char *str =" 400"; char * end; if (400 != PyOS_strtoul(str, &end, 10)) return PyLong_FromLong(1); if (str + strlen(str) != end) return PyLong_FromLong(2); if (400 != PyOS_strtol(str, &end, 10)) return PyLong_FromLong(3); if (str + strlen(str) != end) return PyLong_FromLong(4); return PyLong_FromLong(0); """)]) assert module.from_str() == 0 try: test_strtol() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestLongObject.test_slots _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1f8750>, 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_slots'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_slots'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots'>} 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_slots'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots'>} 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_slots'>, '__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 0x7ff8ee069190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_slots'>, '__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 0x7ff8ee069140> 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 0x7ff8ee069140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_slots'>, '__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_slots'>, '__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 0x7ff8ee01d780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_slots'>, '__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 0x7ff8ee01d870> 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 0x7ff8ee01d870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_slots'>, '__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_slots'>, '__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_slots'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_slots'> 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_slots at 0x7ff8ef21b350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8edfab850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf5fd50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_slots(): module = self.import_extension('foo', [ ("has_sub", "METH_NOARGS", """ PyObject *ret, *obj = PyLong_FromLong(42); if (obj->ob_type != &PyLong_Type) ret = PyLong_FromLong(-2); else { if (obj->ob_type->tp_as_number->nb_subtract) ret = obj->ob_type->tp_as_number->nb_subtract(obj, obj); else ret = PyLong_FromLong(-1); } Py_DECREF(obj); return ret; """), ("has_pow", "METH_NOARGS", """ PyObject *ret, *obj = PyLong_FromLong(42); PyObject *one = PyLong_FromLong(1); if (obj->ob_type->tp_as_number->nb_power) ret = obj->ob_type->tp_as_number->nb_power(obj, one, one); else ret = PyLong_FromLong(-1); Py_DECREF(one); Py_DECREF(obj); return ret; """)]) assert module.has_sub() == 0 assert module.has_pow() == 0 try: test_slots() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________ AppTestLongObject.test_PyLong_AsUnsignedLongLongMask _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf933d0>, 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_PyLong_AsUnsignedLongLongMask'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyLong_AsUnsignedLongLongMask'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyLong_AsUnsignedLongLongMask'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyLong_AsUnsignedLongLongMask'>} 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_PyLong_AsUnsignedLongLongMask'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyLong_AsUnsignedLongLongMask'>} 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_PyLong_AsUnsignedLongLongMask'>, '__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 0x7ff8edf08460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ngLongMask'>, '__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 0x7ff8edf08550> 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 0x7ff8edf08550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ngLongMask'>, '__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_PyLong_AsUnsignedLongLongMask'>, '__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 0x7ff8edf085f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ngLongMask'>, '__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 0x7ff8edf086e0> 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 0x7ff8edf086e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ngLongMask'>, '__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_PyLong_AsUnsignedLongLongMask'>, '__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_PyLong_AsUnsignedLongLongMask'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyLong_AsUnsignedLongLongMask'> 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_PyLong_AsUnsignedLongLongMask at 0x7ff8ef21b3d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8edf5f910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edfa2c10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyLong_AsUnsignedLongLongMask(): module = self.import_extension('foo', [ ("aslongmask", "METH_O", """ uint64_t ret = PyLong_AsUnsignedLongMask(args); if (!ret) return NULL; return PyLong_FromLong(ret); """), ]) assert module.aslongmask(3) == 3 try: test_PyLong_AsUnsignedLongLongMask() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestLongObject.test_as_longlong_and_overflow ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0d5550>, 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_as_longlong_and_overflow'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_as_longlong_and_overflow'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_as_longlong_and_overflow'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_as_longlong_and_overflow'>} 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_as_longlong_and_overflow'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_as_longlong_and_overflow'>} 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_as_longlong_and_overflow'>, '__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 0x7ff8ee098c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_overflow'>, '__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 0x7ff8ee098af0> 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 0x7ff8ee098af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_overflow'>, '__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_as_longlong_and_overflow'>, '__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 0x7ff8ee098b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_overflow'>, '__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 0x7ff8edf2d730> 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 0x7ff8edf2d730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...d_overflow'>, '__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_as_longlong_and_overflow'>, '__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_as_longlong_and_overflow'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_as_longlong_and_overflow'> 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_as_longlong_and_overflow at 0x7ff8ef21b450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestLongObject.w_compile_module of <pypy.module.cpyext.test.test_longobject.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_longobject.AppTestLongObject object at 0x7ff8edf91c10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf91f10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_as_longlong_and_overflow(): module = self.import_extension('foo', [ ("aslonglong_overflow", "METH_O", """ int overflow=0; long long ret = PyLong_AsLongLongAndOverflow(args, &overflow); return PyTuple_Pack(2, PyLong_FromLongLong(ret), PyLong_FromLong(overflow)); """), ]) assert module.aslonglong_overflow(1<<62) == (1<<62, 0) assert module.aslonglong_overflow(1<<63) == (-1, 1) assert module.aslonglong_overflow(-1<<64) == (-1, -1) try: test_as_longlong_and_overflow() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________ AppTestMarshal.test_PyMarshal_ReadObjectFromString ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee1802d0>, 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_PyMarshal_ReadObjectFromString'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyMarshal_ReadObjectFromString'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyMarshal_ReadObjectFromString'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyMarshal_ReadObjectFromString'>} 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_PyMarshal_ReadObjectFromString'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyMarshal_ReadObjectFromString'>} 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_PyMarshal_ReadObjectFromString'>, '__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 0x7ff8edf5beb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromString'>, '__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 0x7ff8ee01d870> 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 0x7ff8ee01d870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromString'>, '__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_PyMarshal_ReadObjectFromString'>, '__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 0x7ff8ee061aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromString'>, '__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 0x7ff8ee069780> 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 0x7ff8ee069780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...FromString'>, '__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_PyMarshal_ReadObjectFromString'>, '__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_PyMarshal_ReadObjectFromString'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyMarshal_ReadObjectFromString'> 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_PyMarshal_ReadObjectFromString at 0x7ff8ef238850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMarshal.w_compile_module of <pypy.module.cpyext.test.test_marshal.AppTestMarsh...TestMarshal.w_import_extension of <pypy.module.cpyext.test.test_marshal.AppTestMarshal object at 0x7ff8edfab290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf832d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyMarshal_ReadObjectFromString(): module = self.import_extension('foo', [ ("mloads", "METH_O", """ char *input = PyBytes_AsString(args); Py_ssize_t length = PyBytes_Size(args); return PyMarshal_ReadObjectFromString(input, length); """)], prologue='#include <marshal.h>') import marshal assert module.mloads(marshal.dumps(42.5)) == 42.5 x = [None, True, (4, 5), b"adkj", u"\u1234"] assert module.mloads(marshal.dumps(x)) == x try: test_PyMarshal_ReadObjectFromString() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________ AppTestMarshal.test_PyMarshal_WriteObjectToString _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0899d0>, 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_PyMarshal_WriteObjectToString'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyMarshal_WriteObjectToString'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyMarshal_WriteObjectToString'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyMarshal_WriteObjectToString'>} 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_PyMarshal_WriteObjectToString'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyMarshal_WriteObjectToString'>} 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_PyMarshal_WriteObjectToString'>, '__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 0x7ff8ee023550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctToString'>, '__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 0x7ff8ee0ea5a0> 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 0x7ff8ee0ea5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctToString'>, '__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_PyMarshal_WriteObjectToString'>, '__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 0x7ff8ee0a7aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctToString'>, '__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 0x7ff8ee0a7230> 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 0x7ff8ee0a7230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctToString'>, '__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_PyMarshal_WriteObjectToString'>, '__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_PyMarshal_WriteObjectToString'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyMarshal_WriteObjectToString'> 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_PyMarshal_WriteObjectToString at 0x7ff8ef2388d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMarshal.w_compile_module of <pypy.module.cpyext.test.test_marshal.AppTestMarsh...TestMarshal.w_import_extension of <pypy.module.cpyext.test.test_marshal.AppTestMarshal object at 0x7ff8edf51a90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf51590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyMarshal_WriteObjectToString(): module = self.import_extension('foo', [ ("mdumps", "METH_VARARGS", """ PyObject *obj; int version; if (!PyArg_ParseTuple(args, "Oi", &obj, &version)) return NULL; return PyMarshal_WriteObjectToString(obj, version); """)], prologue='#include <marshal.h>') import marshal for x in [42, b"foo", u"\u2345", (4, None, False)]: for version in [0, 1, 2]: assert module.mdumps(x, version) == marshal.dumps(x, version) try: test_PyMarshal_WriteObjectToString() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestPyBuffer.test_fillWithObject ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0cc1d0>, 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_fillWithObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithObject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fillWithObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithObject'>} 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_fillWithObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithObject'>} 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_fillWithObject'>, '__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 0x7ff8edfc8640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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 0x7ff8edfc8730> 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 0x7ff8edfc8730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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_fillWithObject'>, '__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 0x7ff8edfc87d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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 0x7ff8edfc88c0> 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 0x7ff8edfc88c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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_fillWithObject'>, '__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_fillWithObject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fillWithObject'> 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_fillWithObject at 0x7ff8ef18fdd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf83cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf839d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fillWithObject(): module = self.import_extension('foo', [ ("fillinfo", "METH_VARARGS", """ Py_buffer buf; PyObject * ret = NULL; PyObject *str = PyBytes_FromString("hello, world."); if (PyBuffer_FillInfo(&buf, str, PyBytes_AsString(str), 13, 0, 0)) { return NULL; } /* Get rid of our own reference to the object, but * the Py_buffer should still have a reference. */ Py_DECREF(str); ret = PyMemoryView_FromBuffer(&buf); if (((PyMemoryViewObject*)ret)->view.obj != NULL) { PyErr_SetString(PyExc_ValueError, "leaked ref"); Py_DECREF(ret); return NULL; } return ret; """)]) result = module.fillinfo() assert b"hello, world." == result try: test_fillWithObject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestPyBuffer.test_fromobject ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0f3550>, 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_fromobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromobject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromobject'>} 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_fromobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromobject'>} 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_fromobject'>, '__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 0x7ff8ee034eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromobject'>, '__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 0x7ff8ee034c80> 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 0x7ff8ee034c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromobject'>, '__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_fromobject'>, '__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 0x7ff8ee034190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromobject'>, '__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 0x7ff8ee0347d0> 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 0x7ff8ee0347d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...fromobject'>, '__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_fromobject'>, '__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_fromobject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromobject'> 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_fromobject at 0x7ff8ef18fed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf51310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf7d490> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromobject(): foo = self.import_extension('foo', [ ("make_view", "METH_O", """ if (!PyObject_CheckBuffer(args)) return Py_None; return PyMemoryView_FromObject(args); """)]) hello = b'hello' mview = foo.make_view(hello) assert mview[0] == hello[0] assert mview.tobytes() == hello try: test_fromobject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestPyBuffer.test_buffer_protocol_app ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03bad0>, 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_buffer_protocol_app'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer_protocol_app'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_buffer_protocol_app'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer_protocol_app'>} 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_buffer_protocol_app'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer_protocol_app'>} 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_buffer_protocol_app'>, '__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 0x7ff8edfa7aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...otocol_app'>, '__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 0x7ff8edfa7870> 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 0x7ff8edfa7870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...otocol_app'>, '__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_buffer_protocol_app'>, '__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 0x7ff8edf0c9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...otocol_app'>, '__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 0x7ff8edf0c820> 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 0x7ff8edf0c820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...otocol_app'>, '__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_buffer_protocol_app'>, '__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_buffer_protocol_app'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_buffer_protocol_app'> 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_buffer_protocol_app at 0x7ff8ef18ff50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf24e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf24f50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_buffer_protocol_app(): module = self.import_module(name='buffer_test') arr = module.PyMyArray(10) y = memoryview(arr) assert y.format == 'i' assert y.shape == (10,) assert len(y) == 10 s = y[3] assert s == 3 try: test_buffer_protocol_app() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestPyBuffer.test_buffer_protocol_capi ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0f3550>, 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_buffer_protocol_capi'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer_protocol_capi'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_buffer_protocol_capi'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer_protocol_capi'>} 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_buffer_protocol_capi'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_buffer_protocol_capi'>} 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_buffer_protocol_capi'>, '__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 0x7ff8ee10b7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tocol_capi'>, '__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 0x7ff8ee10b820> 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 0x7ff8ee10b820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tocol_capi'>, '__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_buffer_protocol_capi'>, '__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 0x7ff8ee10ba00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tocol_capi'>, '__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 0x7ff8ee10baa0> 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 0x7ff8ee10baa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tocol_capi'>, '__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_buffer_protocol_capi'>, '__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_buffer_protocol_capi'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_buffer_protocol_capi'> 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_buffer_protocol_capi at 0x7ff8ef191050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf24850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf7d690> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_buffer_protocol_capi(): foo = self.import_extension('foo', [ ("get_len", "METH_VARARGS", """ Py_buffer view; PyObject* obj = PyTuple_GetItem(args, 0); long ret, vlen; memset(&view, 0, sizeof(Py_buffer)); ret = PyObject_GetBuffer(obj, &view, PyBUF_FULL_RO); if (ret != 0) return NULL; vlen = view.len / view.itemsize; PyBuffer_Release(&view); return PyLong_FromLong(vlen); """), ("test_buffer", "METH_VARARGS", """ Py_buffer* view = NULL; PyObject* obj = PyTuple_GetItem(args, 0); PyObject* memoryview = PyMemoryView_FromObject(obj); if (memoryview == NULL) return NULL; view = PyMemoryView_GET_BUFFER(memoryview); Py_DECREF(memoryview); return PyLong_FromLong(view->len / view->itemsize); """), ("test_contiguous", "METH_O", """ Py_buffer* view; PyObject * memoryview; void * buf = NULL; int ret; Py_ssize_t len; memoryview = PyMemoryView_FromObject(args); if (memoryview == NULL) return NULL; view = PyMemoryView_GET_BUFFER(memoryview); Py_DECREF(memoryview); len = view->len; if (len == 0) return NULL; buf = malloc(len); ret = PyBuffer_ToContiguous(buf, view, view->len, 'A'); if (ret != 0) { free(buf); return NULL; } ret = PyBuffer_FromContiguous(view, buf, view->len, 'A'); free(buf); if (ret != 0) return NULL; Py_RETURN_NONE; """), ("get_contiguous", "METH_O", """ return PyMemoryView_GetContiguous(args, PyBUF_READ, 'C'); """), ("get_readonly", "METH_O", """ Py_buffer view; int readonly; memset(&view, 0, sizeof(view)); if (PyObject_GetBuffer(args, &view, PyBUF_SIMPLE) != 0) { return NULL; } readonly = view.readonly; PyBuffer_Release(&view); return PyLong_FromLong(readonly); """), ]) module = self.import_module(name='buffer_test') arr = module.PyMyArray(10) ten = foo.get_len(arr) assert ten == 10 ten = foo.get_len(b'1234567890') assert ten == 10 ten = foo.test_buffer(arr) assert ten == 10 foo.test_contiguous(arr) contig = foo.get_contiguous(arr) foo.test_contiguous(contig) ro = foo.get_readonly(b'abc') assert ro == 1 try: from _numpypy import multiarray as np except ImportError: skip('pypy built without _numpypy') a = np.arange(20)[::2] skip('not implemented yet') contig = foo.get_contiguous(a) foo.test_contiguous(contig) try: test_buffer_protocol_capi() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestPyBuffer.test_releasebuffer_gc _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0f2650>, 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_releasebuffer_gc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer_gc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_releasebuffer_gc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer_gc'>} 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_releasebuffer_gc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer_gc'>} 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_releasebuffer_gc'>, '__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 0x7ff8edee5780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ebuffer_gc'>, '__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 0x7ff8edee59b0> 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 0x7ff8edee59b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ebuffer_gc'>, '__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_releasebuffer_gc'>, '__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 0x7ff8edee5a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ebuffer_gc'>, '__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 0x7ff8edee5af0> 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 0x7ff8edee5af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ebuffer_gc'>, '__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_releasebuffer_gc'>, '__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_releasebuffer_gc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_releasebuffer_gc'> 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_releasebuffer_gc at 0x7ff8ef1910d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf5fdd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf5fd50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_releasebuffer_gc(): # like test_releasebuffer below, but forces a gc before the first # count check to expose premature release of the intermediate # memoryview that wraps the CPyBuffer. module = self.import_extension('foo', [ ("create_test", "METH_NOARGS", """ PyObject *obj; obj = PyObject_New(PyObject, (PyTypeObject*)type); return obj; """), ("get_cnt", "METH_NOARGS", 'return PyLong_FromLong(cnt);'), ("get_dealloc_cnt", "METH_NOARGS", 'return PyLong_FromLong(dealloc_cnt);'), ], prologue=""" static float test_data = 42.f; static int cnt=0; static int dealloc_cnt=0; static PyHeapTypeObject * type=NULL; void dealloc(PyObject *self) { dealloc_cnt++; } int getbuffer(PyObject *obj, Py_buffer *view, int flags) { cnt ++; memset(view, 0, sizeof(Py_buffer)); view->obj = obj; Py_INCREF(obj); view->ndim = 0; view->buf = (void *) &test_data; view->itemsize = sizeof(float); view->len = 1; view->strides = NULL; view->shape = NULL; view->format = "f"; return 0; } void releasebuffer(PyObject *obj, Py_buffer *view) { cnt --; } """, more_init=""" type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0); type->ht_type.tp_name = "Test"; type->ht_type.tp_basicsize = sizeof(PyObject); type->ht_name = PyUnicode_FromString("Test"); type->ht_type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE; type->ht_type.tp_flags &= ~Py_TPFLAGS_HAVE_GC; type->ht_type.tp_dealloc = dealloc; type->ht_type.tp_as_buffer = &type->as_buffer; type->as_buffer.bf_getbuffer = getbuffer; type->as_buffer.bf_releasebuffer = releasebuffer; if (PyType_Ready(&type->ht_type) < 0) INITERROR; """, ) assert module.get_cnt() == 0 a = memoryview(module.create_test()) # force gc to trigger any stray finalizers on intermediate objects self.debug_collect() assert module.get_cnt() == 1 assert module.get_dealloc_cnt() == 0 del a self.debug_collect() assert module.get_cnt() == 0 assert module.get_dealloc_cnt() == 1 try: test_releasebuffer_gc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestPyBuffer.test_releasebuffer ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03b5d0>, 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_releasebuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_releasebuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer'>} 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_releasebuffer'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_releasebuffer'>} 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_releasebuffer'>, '__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 0x7ff8edf68460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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 0x7ff8edf68690> 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 0x7ff8edf68690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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_releasebuffer'>, '__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 0x7ff8edf682d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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 0x7ff8edf68780> 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 0x7ff8edf68780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...easebuffer'>, '__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_releasebuffer'>, '__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_releasebuffer'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_releasebuffer'> 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_releasebuffer at 0x7ff8ef191150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf1bf90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf5f610> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_releasebuffer(): module = self.import_extension('foo', [ ("create_test", "METH_NOARGS", """ PyObject *obj; obj = PyObject_New(PyObject, (PyTypeObject*)type); return obj; """), ("get_cnt", "METH_NOARGS", 'return PyLong_FromLong(cnt);'), ("get_dealloc_cnt", "METH_NOARGS", 'return PyLong_FromLong(dealloc_cnt);'), ], prologue=""" static float test_data = 42.f; static int cnt=0; static int dealloc_cnt=0; static PyHeapTypeObject * type=NULL; void dealloc(PyObject *self) { dealloc_cnt++; } int getbuffer(PyObject *obj, Py_buffer *view, int flags) { cnt ++; memset(view, 0, sizeof(Py_buffer)); view->obj = obj; /* see the CPython docs for why we need this incref: https://docs.python.org/3.5/c-api/typeobj.html#c.PyBufferProcs.bf_getbuffer */ Py_INCREF(obj); view->ndim = 0; view->buf = (void *) &test_data; view->itemsize = sizeof(float); view->len = 1; view->strides = NULL; view->shape = NULL; view->format = "f"; return 0; } void releasebuffer(PyObject *obj, Py_buffer *view) { cnt --; } """, more_init=""" type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0); type->ht_type.tp_name = "Test"; type->ht_type.tp_basicsize = sizeof(PyObject); type->ht_name = PyUnicode_FromString("Test"); type->ht_type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE; type->ht_type.tp_flags &= ~Py_TPFLAGS_HAVE_GC; type->ht_type.tp_dealloc = dealloc; type->ht_type.tp_as_buffer = &type->as_buffer; type->as_buffer.bf_getbuffer = getbuffer; type->as_buffer.bf_releasebuffer = releasebuffer; if (PyType_Ready(&type->ht_type) < 0) INITERROR; """, ) import gc assert module.get_cnt() == 0 a = memoryview(module.create_test()) assert module.get_cnt() == 1 assert module.get_dealloc_cnt() == 0 del a self.debug_collect() assert module.get_cnt() == 0 assert module.get_dealloc_cnt() == 1 try: test_releasebuffer() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestPyBuffer.test_FromMemory_readonly ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03b850>, 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_FromMemory_readonly'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromMemory_readonly'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_FromMemory_readonly'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromMemory_readonly'>} 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_FromMemory_readonly'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromMemory_readonly'>} 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_FromMemory_readonly'>, '__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 0x7ff8edf68050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_readonly'>, '__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 0x7ff8edee5410> 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 0x7ff8edee5410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_readonly'>, '__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_FromMemory_readonly'>, '__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 0x7ff8edee53c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_readonly'>, '__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 0x7ff8edee5640> 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 0x7ff8edee5640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...y_readonly'>, '__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_FromMemory_readonly'>, '__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_FromMemory_readonly'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_FromMemory_readonly'> 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_FromMemory_readonly at 0x7ff8ef1911d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf7d610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf7d310> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_FromMemory_readonly(): module = self.import_extension('foo', [ ('new', 'METH_NOARGS', """ static char s[5] = "hello"; return PyMemoryView_FromMemory(s, 4, PyBUF_READ); """)]) mv = module.new() assert mv.readonly == True assert mv.tobytes() == b'hell' try: test_FromMemory_readonly() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestPyBuffer.test_FromMemory_readwrite ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee01f0d0>, 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_FromMemory_readwrite'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromMemory_readwrite'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_FromMemory_readwrite'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromMemory_readwrite'>} 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_FromMemory_readwrite'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromMemory_readwrite'>} 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_FromMemory_readwrite'>, '__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 0x7ff8edfc8320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._readwrite'>, '__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 0x7ff8edf47b40> 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 0x7ff8edf47b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._readwrite'>, '__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_FromMemory_readwrite'>, '__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 0x7ff8edf47190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._readwrite'>, '__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 0x7ff8ee034aa0> 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 0x7ff8ee034aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._readwrite'>, '__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_FromMemory_readwrite'>, '__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_FromMemory_readwrite'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_FromMemory_readwrite'> 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_FromMemory_readwrite at 0x7ff8ef191250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf7df10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf83d10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_FromMemory_readwrite(): module = self.import_extension('foo', [ ('new', 'METH_NOARGS', """ static char s[5] = "hello"; return PyMemoryView_FromMemory(s, 4, PyBUF_WRITE); """)]) mv = module.new() assert mv.readonly == False assert mv.tobytes() == b'hell' try: test_FromMemory_readwrite() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestPyBuffer.test_FromBuffer_NULL _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0d6a50>, 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_FromBuffer_NULL'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromBuffer_NULL'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_FromBuffer_NULL'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromBuffer_NULL'>} 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_FromBuffer_NULL'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_FromBuffer_NULL'>} 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_FromBuffer_NULL'>, '__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 0x7ff8ede933c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_NULL'>, '__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 0x7ff8ede93410> 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 0x7ff8ede93410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_NULL'>, '__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_FromBuffer_NULL'>, '__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 0x7ff8ede93500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_NULL'>, '__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 0x7ff8ede935a0> 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 0x7ff8ede935a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...uffer_NULL'>, '__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_FromBuffer_NULL'>, '__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_FromBuffer_NULL'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_FromBuffer_NULL'> 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_FromBuffer_NULL at 0x7ff8ef1912d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edecafd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf11a10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_FromBuffer_NULL(): module = self.import_extension('foo', [ ('new', 'METH_NOARGS', """ Py_buffer info; if (PyBuffer_FillInfo(&info, NULL, NULL, 1, 1, PyBUF_FULL_RO) < 0) return NULL; return PyMemoryView_FromBuffer(&info); """)]) raises(ValueError, module.new) try: test_FromBuffer_NULL() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestPyBuffer.test_release_before_dealloc __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0d69d0>, 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_release_before_dealloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release_before_dealloc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_release_before_dealloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release_before_dealloc'>} 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_release_before_dealloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_release_before_dealloc'>} 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_release_before_dealloc'>, '__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 0x7ff8edeeb140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_dealloc'>, '__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 0x7ff8edeebdc0> 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 0x7ff8edeebdc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_dealloc'>, '__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_release_before_dealloc'>, '__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 0x7ff8edeeb820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_dealloc'>, '__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 0x7ff8edeeb370> 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 0x7ff8edeeb370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...re_dealloc'>, '__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_release_before_dealloc'>, '__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_release_before_dealloc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_release_before_dealloc'> 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_release_before_dealloc at 0x7ff8ef191350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBuffer.w_compile_module of <pypy.module.cpyext.test.test_memoryobject.AppTes...uffer.w_import_extension of <pypy.module.cpyext.test.test_memoryobject.AppTestPyBuffer object at 0x7ff8edf83d10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edecadd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_release_before_dealloc(): module = self.import_extension("foo", [ ("get_type","METH_NOARGS", """ return PyType_FromSpec(&HeapCTypeWithBuffer_spec); """)], prologue=""" typedef struct { PyObject_HEAD int value; } HeapCTypeObject; typedef struct { HeapCTypeObject base; char buffer[4]; } HeapCTypeWithBufferObject; static int heapctypewithbuffer_getbuffer(HeapCTypeWithBufferObject *self, Py_buffer *view, int flags) { self->buffer[0] = '1'; self->buffer[1] = '2'; self->buffer[2] = '3'; self->buffer[3] = '4'; int ret = PyBuffer_FillInfo( view, (PyObject*)self, (void *)self->buffer, 4, 1, flags); return ret; } static void heapctypewithbuffer_releasebuffer(HeapCTypeWithBufferObject *self, Py_buffer *view) { /* Make sure this is called before the dealloc */ assert(view->obj == (void*) self); } static PyType_Slot HeapCTypeWithBuffer_slots[] = { {Py_bf_getbuffer, heapctypewithbuffer_getbuffer}, {Py_bf_releasebuffer, heapctypewithbuffer_releasebuffer}, {0, 0}, }; static PyType_Spec HeapCTypeWithBuffer_spec = { "HeapCTypeWithBuffer", sizeof(HeapCTypeWithBufferObject), 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, HeapCTypeWithBuffer_slots }; """) HeapCTypeWithBuffer = module.get_type() inst = HeapCTypeWithBuffer() b = bytes(inst) assert b == b"1234" # release the buffer del inst import gc; gc.collect() try: test_release_before_dealloc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestMethodObject.test_call_METH_NOARGS ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03b150>, 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_call_METH_NOARGS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_NOARGS'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_METH_NOARGS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_NOARGS'>} 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_call_METH_NOARGS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_NOARGS'>} 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_call_METH_NOARGS'>, '__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 0x7ff8edeadaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ETH_NOARGS'>, '__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 0x7ff8edeadb90> 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 0x7ff8edeadb90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ETH_NOARGS'>, '__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_call_METH_NOARGS'>, '__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 0x7ff8edeadc30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ETH_NOARGS'>, '__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 0x7ff8edeadd20> 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 0x7ff8edeadd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ETH_NOARGS'>, '__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_call_METH_NOARGS'>, '__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_call_METH_NOARGS'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_METH_NOARGS'> 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_call_METH_NOARGS at 0x7ff8ef1a91d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edf5f5d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf3d610> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_call_METH_NOARGS(): mod = self.import_extension('MyModule', [ ('getarg_NO', 'METH_NOARGS', ''' if(args) { Py_INCREF(args); return args; } else { Py_INCREF(Py_None); return Py_None; } ''' ), ]) assert mod.getarg_NO() is None excinfo = raises(TypeError, mod.getarg_NO, 1) assert "(1 given)" in str(excinfo.value) raises(TypeError, mod.getarg_NO, 1, 1) try: test_call_METH_NOARGS() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestMethodObject.test_call_METH_O _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edef7050>, 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_call_METH_O'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_O'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_METH_O'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_O'>} 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_call_METH_O'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_O'>} 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_call_METH_O'>, '__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 0x7ff8edea9370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...all_METH_O'>, '__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 0x7ff8edea9550> 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 0x7ff8edea9550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...all_METH_O'>, '__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_call_METH_O'>, '__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 0x7ff8edea9640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...all_METH_O'>, '__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 0x7ff8edea96e0> 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 0x7ff8edea96e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...all_METH_O'>, '__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_call_METH_O'>, '__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_call_METH_O'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_METH_O'> 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_call_METH_O at 0x7ff8ef1a9250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edeca890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edeca810> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_call_METH_O(): mod = self.import_extension('MyModule', [ ('getarg_O', 'METH_O', ''' Py_INCREF(args); return args; ''' ), ]) assert mod.getarg_O(1) == 1 assert mod.getarg_O.__name__ == "getarg_O" raises(TypeError, mod.getarg_O) raises(TypeError, mod.getarg_O, 1, 1) try: test_call_METH_O() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestMethodObject.test_call_METH_VARARGS __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03b150>, 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_call_METH_VARARGS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_VARARGS'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_METH_VARARGS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_VARARGS'>} 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_call_METH_VARARGS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_VARARGS'>} 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_call_METH_VARARGS'>, '__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 0x7ff8edeadaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...TH_VARARGS'>, '__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 0x7ff8edead9b0> 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 0x7ff8edead9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...TH_VARARGS'>, '__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_call_METH_VARARGS'>, '__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 0x7ff8edead140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...TH_VARARGS'>, '__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 0x7ff8edead3c0> 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 0x7ff8edead3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...TH_VARARGS'>, '__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_call_METH_VARARGS'>, '__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_call_METH_VARARGS'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_METH_VARARGS'> 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_call_METH_VARARGS at 0x7ff8ef1a92d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edf371d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede824d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_call_METH_VARARGS(): mod = self.import_extension('MyModule', [ ('getarg_VARARGS', 'METH_VARARGS', ''' return Py_BuildValue("Ol", args, args->ob_refcnt); ''' ), ]) # check that we pass the expected tuple of arguments AND that the # recnt is 1. In particular, on PyPy refcnt==1 means that we created # the PyObject tuple directly, without passing from a w_tuple; as # such, the tuple will be immediately freed after the call, without # having to wait until the GC runs. # tup, refcnt = mod.getarg_VARARGS() assert tup == () # the empty tuple is shared on CPython, so the refcnt will be >1. On # PyPy it is not shared, though. if not self.runappdirect: assert refcnt == 1 # tup, refcnt = mod.getarg_VARARGS(1) assert tup == (1,) assert refcnt == 1 # tup, refcnt = mod.getarg_VARARGS(1, 2, 3) assert tup == (1, 2, 3) assert refcnt == 1 # raises(TypeError, mod.getarg_VARARGS, k=1) try: test_call_METH_VARARGS() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________ AppTestMethodObject.test_call_METH_VARARGS_FASTCALL ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edef7050>, 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_call_METH_VARARGS_FASTCALL'>, '...lticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_VARARGS_FASTCALL'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_METH_VARARGS_FASTCALL'>, '...lticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_VARARGS_FASTCALL'>} 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_call_METH_VARARGS_FASTCALL'>, '...lticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_VARARGS_FASTCALL'>} 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_call_METH_VARARGS_FASTCALL'>, '__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 0x7ff8ede62500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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 0x7ff8ede625a0> 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 0x7ff8ede625a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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_call_METH_VARARGS_FASTCALL'>, '__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 0x7ff8ede62690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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 0x7ff8ede627d0> 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 0x7ff8ede627d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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_call_METH_VARARGS_FASTCALL'>, '__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_call_METH_VARARGS_FASTCALL'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_METH_VARARGS_FASTCALL'> 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_call_METH_VARARGS_FASTCALL at 0x7ff8ef1a9350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8ee004490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee0044d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_call_METH_VARARGS_FASTCALL(): mod = self.import_extension('MyModule', [ ('getarg_VA_FASTCALL', 'METH_VARARGS | METH_FASTCALL', ''' PyObject *arg_tuple = PyTuple_New(len_args); for (Py_ssize_t i =0 ; i < len_args; i++) { Py_INCREF(args[i]); PyTuple_SetItem(arg_tuple, i, args[i]); } return arg_tuple; ''' ), ]) tup = mod.getarg_VA_FASTCALL() assert tup == () tup = mod.getarg_VA_FASTCALL(1) assert tup == (1,) tup = mod.getarg_VA_FASTCALL(1, 2, 3) assert tup == (1, 2, 3) raises(TypeError, mod.getarg_VA_FASTCALL, k=1) try: test_call_METH_VARARGS_FASTCALL() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestMethodObject.test_call_METH_KEYWORDS __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edef73d0>, 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_call_METH_KEYWORDS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_KEYWORDS'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_METH_KEYWORDS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_KEYWORDS'>} 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_call_METH_KEYWORDS'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_KEYWORDS'>} 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_call_METH_KEYWORDS'>, '__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 0x7ff8edf74500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...H_KEYWORDS'>, '__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 0x7ff8ef1b6280> 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 0x7ff8ef1b6280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...H_KEYWORDS'>, '__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_call_METH_KEYWORDS'>, '__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 0x7ff8ee0590a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...H_KEYWORDS'>, '__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 0x7ff8ee059e10> 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 0x7ff8ee059e10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...H_KEYWORDS'>, '__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_call_METH_KEYWORDS'>, '__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_call_METH_KEYWORDS'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_METH_KEYWORDS'> 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_call_METH_KEYWORDS at 0x7ff8ef1a93d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edeb9cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edf83b10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_call_METH_KEYWORDS(): mod = self.import_extension('MyModule', [ ('getarg_KW', 'METH_VARARGS | METH_KEYWORDS', ''' if (!kwargs) kwargs = Py_None; return Py_BuildValue("OO", args, kwargs); ''' ), ]) assert mod.getarg_KW(1) == ((1,), None) assert mod.getarg_KW(1, 2) == ((1, 2), None) assert mod.getarg_KW(a=3, b=4) == ((), {'a': 3, 'b': 4}) assert mod.getarg_KW(1, 2, a=3, b=4) == ((1, 2), {'a': 3, 'b': 4}) assert mod.getarg_KW.__name__ == "getarg_KW" assert mod.getarg_KW(*(), **{}) == ((), {}) try: test_call_METH_KEYWORDS() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________ AppTestMethodObject.test_call_METH_KEYWORDS_FASTCALL _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03fed0>, 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_call_METH_KEYWORDS_FASTCALL'>, ...ticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_KEYWORDS_FASTCALL'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_call_METH_KEYWORDS_FASTCALL'>, ...ticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_KEYWORDS_FASTCALL'>} 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_call_METH_KEYWORDS_FASTCALL'>, ...ticall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_call_METH_KEYWORDS_FASTCALL'>} 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_call_METH_KEYWORDS_FASTCALL'>, '__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 0x7ff8ede7d320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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 0x7ff8ede7d500> 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 0x7ff8ede7d500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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_call_METH_KEYWORDS_FASTCALL'>, '__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 0x7ff8ede7d5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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 0x7ff8ede7d690> 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 0x7ff8ede7d690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...S_FASTCALL'>, '__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_call_METH_KEYWORDS_FASTCALL'>, '__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_call_METH_KEYWORDS_FASTCALL'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_call_METH_KEYWORDS_FASTCALL'> 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_call_METH_KEYWORDS_FASTCALL at 0x7ff8ef1a9450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edea0710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edea0650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_call_METH_KEYWORDS_FASTCALL(): mod = self.import_extension('MyModule', [ ('getarg_KW_FASTCALL', 'METH_FASTCALL | METH_KEYWORDS', ''' Py_ssize_t len_all_args = len_args; if (!kwnames) { kwnames = Py_None; } else { len_all_args += PyTuple_Size(kwnames); } PyObject *arg_tuple = PyTuple_New(len_all_args); for (Py_ssize_t i = 0 ; i < len_all_args; i++) { Py_INCREF(args[i]); PyTuple_SetItem(arg_tuple, i, args[i]); } return Py_BuildValue("NO", arg_tuple, kwnames); ''' ), ]) assert mod.getarg_KW_FASTCALL(1) == ((1,), None) assert mod.getarg_KW_FASTCALL(1, 2) == ((1, 2), None) assert mod.getarg_KW_FASTCALL(a=3, b=4) == ((3, 4), ('a', 'b')) assert mod.getarg_KW_FASTCALL(1, 2, a=3, b=4) == ((1, 2, 3, 4), ('a', 'b')) assert mod.getarg_KW_FASTCALL.__name__ == "getarg_KW_FASTCALL" assert mod.getarg_KW_FASTCALL(*(), **{}) == ((), None) res = mod.getarg_KW_FASTCALL(1, 2, a=5, b=6, *[3, 4], **{'c': 7}) assert res[0][:4] == (1, 2, 3, 4) # positional # keyword arguments may be ordered differently so compare as dict: assert dict(zip(res[1], res[0][4:])) == {'a': 5, 'b': 6, 'c': 7} args = tuple(range(50)) kwargs = {str(i): i for i in range(100)} res = mod.getarg_KW_FASTCALL(*args, **kwargs) assert res[0][:len(args)] == args assert dict(zip(res[1], res[0][len(args):])) == kwargs try: test_call_METH_KEYWORDS_FASTCALL() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestMethodObject.test_func_attributes ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0ca850>, 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_func_attributes'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_func_attributes'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_func_attributes'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_func_attributes'>} 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_func_attributes'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_func_attributes'>} 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_func_attributes'>, '__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 0x7ff8edf3b6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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 0x7ff8ee001320> 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 0x7ff8ee001320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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_func_attributes'>, '__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 0x7ff8ee0010a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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 0x7ff8ee001230> 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 0x7ff8ee001230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...attributes'>, '__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_func_attributes'>, '__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_func_attributes'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_func_attributes'> 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_func_attributes at 0x7ff8ef1a94d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edf37190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edecacd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_func_attributes(): mod = self.import_extension('MyModule', [ ('isCFunction', 'METH_O', ''' if(PyCFunction_Check(args)) { PyCFunctionObject* func = (PyCFunctionObject*)args; return PyUnicode_FromString(func->m_ml->ml_name); } else { Py_RETURN_FALSE; } ''' ), ('getModule', 'METH_O', ''' if(PyCFunction_Check(args)) { PyCFunctionObject* func = (PyCFunctionObject*)args; Py_INCREF(func->m_module); return func->m_module; } else { Py_RETURN_FALSE; } ''' ), ('isSameFunction', 'METH_O', ''' PyCFunction ptr = PyCFunction_GetFunction(args); if (!ptr) return NULL; if (ptr == (PyCFunction)MyModule_getModule) Py_RETURN_TRUE; else Py_RETURN_FALSE; ''' ), ]) assert mod.isCFunction(mod.getModule) == "getModule" assert mod.getModule(mod.getModule) == 'MyModule' if self.runappdirect: # XXX: fails untranslated assert mod.isSameFunction(mod.getModule) raises(SystemError, mod.isSameFunction, 1) try: test_func_attributes() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestMethodObject.test_function_as_method __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee11ae50>, 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_function_as_method'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_as_method'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_function_as_method'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_as_method'>} 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_function_as_method'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_function_as_method'>} 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_function_as_method'>, '__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 0x7ff8ede587d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._as_method'>, '__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 0x7ff8ede58a50> 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 0x7ff8ede58a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._as_method'>, '__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_function_as_method'>, '__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 0x7ff8ede58b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._as_method'>, '__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 0x7ff8ede58be0> 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 0x7ff8ede58be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._as_method'>, '__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_function_as_method'>, '__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_function_as_method'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_function_as_method'> 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_function_as_method at 0x7ff8ef1a9550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edf834d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edea0350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_function_as_method(): # Unlike user functions, builtins don't become methods mod = self.import_extension('foo', [ ('f', 'METH_NOARGS', ''' return PyLong_FromLong(42); '''), ]) class A(object): pass A.f = mod.f A.g = lambda: 42 # Unbound method assert A.f() == A.g() == 42 # Bound method assert A().f() == 42 raises(TypeError, A().g) try: test_function_as_method() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestMethodObject.test_check ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0ca850>, 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_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check'>} 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_check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_check'>} 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_check'>, '__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 0x7ff8ede153c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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 0x7ff8ede15410> 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 0x7ff8ede15410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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_check'>, '__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 0x7ff8ede15500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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 0x7ff8ede155a0> 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 0x7ff8ede155a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_check'>, '__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_check'>, '__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_check'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_check'> 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_check at 0x7ff8ef1a95d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8ee101f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee101a10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_check(): mod = self.import_extension('foo', [ ('check', 'METH_O', ''' return PyLong_FromLong(PyCFunction_Check(args)); '''), ]) from math import degrees assert mod.check(degrees) == 1 assert mod.check(list) == 0 assert mod.check(sorted) == 1 def func(): pass class A(object): def meth(self): pass @staticmethod def stat(): pass assert mod.check(func) == 0 assert mod.check(A) == 0 assert mod.check(A.meth) == 0 assert mod.check(A.stat) == 0 try: test_check() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestMethodObject.test_module_attribute ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee11ae50>, 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_module_attribute'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_attribute'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_module_attribute'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_attribute'>} 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_module_attribute'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_attribute'>} 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_module_attribute'>, '__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 0x7ff8edead1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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 0x7ff8edeadaa0> 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 0x7ff8edeadaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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_module_attribute'>, '__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 0x7ff8ede58910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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 0x7ff8ede58a50> 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 0x7ff8ede58a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._attribute'>, '__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_module_attribute'>, '__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_module_attribute'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_module_attribute'> 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_module_attribute at 0x7ff8ef1a9650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edea4290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edea4c10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_module_attribute(): mod = self.import_extension('MyModule', [ ('getarg_NO', 'METH_NOARGS', ''' Py_INCREF(Py_None); return Py_None; ''' ), ]) assert mod.getarg_NO() is None assert mod.getarg_NO.__module__ == 'MyModule' mod.getarg_NO.__module__ = 'foobar' assert mod.getarg_NO.__module__ == 'foobar' try: test_module_attribute() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestMethodObject.test_callfunc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee03fed0>, 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_callfunc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_callfunc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_callfunc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_callfunc'>} 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_callfunc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_callfunc'>} 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_callfunc'>, '__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 0x7ff8ede1d460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_callfunc'>, '__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 0x7ff8ede1d640> 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 0x7ff8ede1d640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_callfunc'>, '__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_callfunc'>, '__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 0x7ff8ede1d730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_callfunc'>, '__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 0x7ff8ede1d7d0> 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 0x7ff8ede1d7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_callfunc'>, '__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_callfunc'>, '__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_callfunc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_callfunc'> 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_callfunc at 0x7ff8ef1a96d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edea4750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee101650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_callfunc(): mod = self.import_extension('foo', [ ('callfunc', 'METH_VARARGS', ''' PyObject *func, *argseq=NULL, *kwargs=NULL; if (!PyArg_ParseTuple(args, "O|OO", &func, &argseq, &kwargs)) { return NULL; } if (!PyCFunction_Check(func)) { Py_RETURN_FALSE; } if (argseq == NULL) { return PyCFunction_Call(func, NULL, NULL); } if (kwargs == NULL) { return PyCFunction_Call(func, argseq, NULL); } return PyCFunction_Call(func, argseq, kwargs); ''' ), # Define some C functions so we can test this ('func_NOARGS', 'METH_NOARGS', ''' Py_RETURN_TRUE; '''), ('func_KW', 'METH_VARARGS | METH_KEYWORDS', ''' if (!kwargs) kwargs = Py_None; return Py_BuildValue("OO", args, kwargs); ''' ), ]) ret = mod.callfunc(mod.func_NOARGS, ()) assert ret is True ret = mod.callfunc(mod.func_KW, (1, 2, 3), {'a':'a', 'b':'b', 'c':'c'}) assert ret == ((1, 2, 3), {'a':'a', 'b':'b', 'c':'c'}) with raises(TypeError): mod.callfunc(mod.func_NOARGS, (), {'a': 'a'}) with raises(TypeError): mod.callfunc(mod.func_NOARGS, (1, 2, 3)) try: test_callfunc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestMethodObject.test_wrapper _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edef73d0>, 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_wrapper'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_wrapper'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_wrapper'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_wrapper'>} 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_wrapper'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_wrapper'>} 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_wrapper'>, '__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 0x7ff8edead9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_wrapper'>, '__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 0x7ff8edfe4eb0> 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 0x7ff8edfe4eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_wrapper'>, '__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_wrapper'>, '__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 0x7ff8ede7da00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_wrapper'>, '__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 0x7ff8ede7dc80> 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 0x7ff8ede7dc80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_wrapper'>, '__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_wrapper'>, '__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_wrapper'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_wrapper'> 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_wrapper at 0x7ff8ef1a9750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8edea0a10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee101310> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_wrapper(): # Copy the Cython 3.0.0alpha10 version of specmethodstring tests mod = self.import_module(name="specmethdocstring") c = mod.C() assert c.__iter__.__doc__ == "usable docstring" assert mod.C.__qualname__ == "C" assert c.__iter__.__qualname__ == "C.__iter__" assert type(c.__iter__).__doc__.startswith('instancemethod(function, instance)') assert mod.C.__next__.__doc__ == "usable docstring" assert mod.C.__next__.__text_signature__ == '($self, /)' try: test_wrapper() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestMethodObject.test_module_name _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf445d0>, 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_module_name'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_name'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_module_name'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_name'>} 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_module_name'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_module_name'>} 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_module_name'>, '__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 0x7ff8ede27690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_name'>, '__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 0x7ff8ede27870> 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 0x7ff8ede27870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_name'>, '__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_module_name'>, '__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 0x7ff8ede27960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_name'>, '__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 0x7ff8ede27a00> 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 0x7ff8ede27a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...odule_name'>, '__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_module_name'>, '__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_module_name'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_module_name'> 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_module_name at 0x7ff8ef1a97d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8ee101390>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee101850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_module_name(): # issue 3993 mod = self.import_module(name="test_func") assert mod.f.__module__ == "test_func" try: test_module_name() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestMethodObject.test_min_max _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edef73d0>, 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_min_max'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_min_max'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_min_max'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_min_max'>} 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_min_max'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_min_max'>} 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_min_max'>, '__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 0x7ff8edfe23c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_min_max'>, '__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 0x7ff8edead050> 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 0x7ff8edead050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_min_max'>, '__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_min_max'>, '__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 0x7ff8edead3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_min_max'>, '__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 0x7ff8edeadaa0> 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 0x7ff8edeadaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_min_max'>, '__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_min_max'>, '__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_min_max'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_min_max'> 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_min_max at 0x7ff8ef1a9850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMethodObject.w_compile_module of <pypy.module.cpyext.test.test_methodobject.Ap...t.w_import_extension of <pypy.module.cpyext.test.test_methodobject.AppTestMethodObject object at 0x7ff8ede4f450>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede03c10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_min_max(): mod = self.import_module(name="builtin_min_max") mod.test_max2() try: test_min_max() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestMisc.test_pyos_inputhook ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee01f0d0>, 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_pyos_inputhook'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyos_inputhook'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pyos_inputhook'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyos_inputhook'>} 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_pyos_inputhook'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pyos_inputhook'>} 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_pyos_inputhook'>, '__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 0x7ff8edd4e8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._inputhook'>, '__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 0x7ff8edd4e9b0> 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 0x7ff8edd4e9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._inputhook'>, '__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_pyos_inputhook'>, '__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 0x7ff8edd4ea50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._inputhook'>, '__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 0x7ff8edd4eb40> 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 0x7ff8edd4eb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._inputhook'>, '__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_pyos_inputhook'>, '__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_pyos_inputhook'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pyos_inputhook'> 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_pyos_inputhook at 0x7ff8ef1a9050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMisc.w_compile_module of <pypy.module.cpyext.test.test_misc.AppTestMisc object...ethod AppTestMisc.w_import_extension of <pypy.module.cpyext.test.test_misc.AppTestMisc object at 0x7ff8ee101dd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee101990> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pyos_inputhook(): module = self.import_extension('foo', [ ("set_pyos_inputhook", "METH_NOARGS", ''' PyOS_InputHook = &my_callback; Py_RETURN_NONE; '''), ("fetch_value", "METH_NOARGS", ''' return PyLong_FromLong(my_flag); '''), ], prologue=''' static long my_flag = 0; static int my_callback(void) { return ++my_flag; } ''') try: import __pypy__ except ImportError: skip("only runs on top of pypy") assert module.fetch_value() == 0 __pypy__.pyos_inputhook() assert module.fetch_value() == 0 module.set_pyos_inputhook() # <= set assert module.fetch_value() == 0 __pypy__.pyos_inputhook() assert module.fetch_value() == 1 __pypy__.pyos_inputhook() assert module.fetch_value() == 2 assert module.fetch_value() == 2 try: test_pyos_inputhook() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestModuleObject.test_getdef_basic _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0fbc50>, 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_getdef_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getdef_basic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getdef_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getdef_basic'>} 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_getdef_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getdef_basic'>} 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_getdef_basic'>, '__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 0x7ff8edd47730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tdef_basic'>, '__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 0x7ff8edd47820> 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 0x7ff8edd47820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tdef_basic'>, '__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_getdef_basic'>, '__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 0x7ff8edd478c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tdef_basic'>, '__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 0x7ff8edd479b0> 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 0x7ff8edd479b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tdef_basic'>, '__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_getdef_basic'>, '__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_getdef_basic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getdef_basic'> 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_getdef_basic at 0x7ff8ef1cf850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ede3e3d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede68850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getdef_basic(): module = self.import_extension('foo', [ ("check_getdef_same", "METH_NOARGS", """ return PyBool_FromLong(PyModule_GetDef(self) == &moduledef); """ )], prologue=""" static struct PyModuleDef moduledef; """) assert module.check_getdef_same() # module-level functions must have __self__ set to the module # so that inspect.signature() can strip the $module parameter (issue 5368) assert module.check_getdef_same.__self__ is module try: test_getdef_basic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestModuleObject.test_getstate _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edeea2d0>, 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_getstate'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getstate'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getstate'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getstate'>} 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_getstate'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getstate'>} 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_getstate'>, '__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 0x7ff8edd4e3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getstate'>, '__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 0x7ff8ede1d3c0> 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 0x7ff8ede1d3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getstate'>, '__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_getstate'>, '__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 0x7ff8ede1d4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getstate'>, '__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 0x7ff8ede1dd20> 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 0x7ff8ede1dd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_getstate'>, '__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_getstate'>, '__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_getstate'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getstate'> 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_getstate at 0x7ff8ef1cf8d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ede066d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede06b10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getstate(): module = self.import_extension('foo', [ ("check_mod_getstate", "METH_NOARGS", """ struct module_state { int foo[51200]; }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "module_getstate_myextension", NULL, sizeof(struct module_state) }; PyObject *module = PyModule_Create(&moduledef); int *p = (int *)PyModule_GetState(module); int i; for (i = 0; i < 51200; i++) if (p[i] != 0) return PyBool_FromLong(0); Py_DECREF(module); return PyBool_FromLong(1); """ )]) assert module.check_mod_getstate() try: test_getstate() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestModuleObject.test___file__ _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ee0fbc50>, 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___file__'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test___file__'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test___file__'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test___file__'>} 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___file__'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test___file__'>} 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___file__'>, '__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 0x7ff8edd6b690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t___file__'>, '__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 0x7ff8edd6b910> 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 0x7ff8edd6b910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t___file__'>, '__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___file__'>, '__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 0x7ff8edd6ba00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t___file__'>, '__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 0x7ff8edd6baa0> 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 0x7ff8edd6baa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t___file__'>, '__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___file__'>, '__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___file__'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test___file__'> 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___file__ at 0x7ff8ef1cf950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ee1019d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ee1012d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test___file__(): module = self.import_extension('foo', [ ("check___file__", "METH_NOARGS", """ PyObject * f = PyUnicode_InternFromString("__file__"); PyObject *result = PyObject_GetItem(pyx_d, f); Py_XINCREF(result); Py_DECREF(f); return result; """ )], prologue=""" static PyObject * pyx_d; """, more_init=""" pyx_d = PyModule_GetDict(mod); """) assert 'foo' in module.check___file__() try: test___file__() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestModuleObject.test_PyModule_AddType ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edee90d0>, 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_PyModule_AddType'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyModule_AddType'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyModule_AddType'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyModule_AddType'>} 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_PyModule_AddType'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyModule_AddType'>} 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_PyModule_AddType'>, '__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 0x7ff8eddf05a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_AddType'>, '__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 0x7ff8eddf0640> 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 0x7ff8eddf0640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_AddType'>, '__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_PyModule_AddType'>, '__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 0x7ff8eddf0730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_AddType'>, '__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 0x7ff8eddf0870> 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 0x7ff8eddf0870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...le_AddType'>, '__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_PyModule_AddType'>, '__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_PyModule_AddType'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyModule_AddType'> 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_PyModule_AddType at 0x7ff8ef1cf9d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ee101850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede06950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyModule_AddType(): module = self.import_extension('foo', [ ('is_ascii', "METH_O", ''' if (!PyUnicode_Check(args)) { Py_RETURN_FALSE; } if (PyUnicode_IS_ASCII(args)) { Py_RETURN_TRUE; } Py_RETURN_FALSE; '''), ], prologue=""" #include <Python.h> PyTypeObject PyUnicodeSubtype = { PyVarObject_HEAD_INIT(NULL,0) "foo.subtype", /* tp_name*/ sizeof(PyUnicodeObject), /* tp_basicsize*/ 0 /* tp_itemsize */ }; """, more_init = ''' PyUnicodeSubtype.tp_alloc = NULL; PyUnicodeSubtype.tp_free = NULL; PyUnicodeSubtype.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE; PyUnicodeSubtype.tp_itemsize = sizeof(char); PyUnicodeSubtype.tp_base = &PyUnicode_Type; PyModule_AddType(mod, &PyUnicodeSubtype); ''') a = module.subtype('abc') assert module.is_ascii(a) is True try: test_PyModule_AddType() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestModuleObject.test_getobject ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eded62d0>, 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_getobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getobject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getobject'>} 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_getobject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getobject'>} 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_getobject'>, '__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 0x7ff8ede58730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getobject'>, '__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 0x7ff8ede58140> 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 0x7ff8ede58140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getobject'>, '__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_getobject'>, '__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 0x7ff8ede58910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getobject'>, '__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 0x7ff8ede58370> 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 0x7ff8ede58370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getobject'>, '__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_getobject'>, '__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_getobject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getobject'> 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_getobject at 0x7ff8ef1cfa50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ede06450>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede06d90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getobject(): module = self.import_extension('foo', [ ('get_name', "METH_O", """ return PyModule_GetNameObject(args); """), ('get_file', "METH_O", """ return PyModule_GetFilenameObject(args); """),]) import os assert module.get_name(module) == "foo" # should return full path to file with `foo.pypy*` file = module.get_file(module) assert "foo.pypy" in file assert os.path.exists(file) try: test_getobject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestModuleObject.test_basic ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edee90d0>, 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_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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_basic'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_basic'>} 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_basic'>, '__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 0x7ff8edddc640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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 0x7ff8edddc820> 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 0x7ff8edddc820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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_basic'>, '__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 0x7ff8edddc910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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 0x7ff8edddc9b0> 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 0x7ff8edddc9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_basic'>, '__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_basic'>, '__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_basic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_basic'> 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_basic at 0x7ff8ef1cfad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ede3e990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd7f090> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_basic(): from types import ModuleType module = self.import_module(name='multiphase', use_imp=True) assert isinstance(module, ModuleType) assert module.__name__ == 'multiphase' assert module.__doc__ == "example docstring" try: test_basic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestModuleObject.test_getdef ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edfe91d0>, 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_getdef'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getdef'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getdef'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getdef'>} 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_getdef'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getdef'>} 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_getdef'>, '__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 0x7ff8ede27320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_getdef'>, '__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 0x7ff8ede27230> 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 0x7ff8ede27230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_getdef'>, '__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_getdef'>, '__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 0x7ff8ede27870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_getdef'>, '__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 0x7ff8ede27410> 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 0x7ff8ede27410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_getdef'>, '__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_getdef'>, '__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_getdef'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getdef'> 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_getdef at 0x7ff8ef1cfb50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ede06a10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ede06dd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getdef(): from types import ModuleType module = self.import_module(name='multiphase', use_imp=True) assert module.check_getdef_same() try: test_getdef() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestModuleObject.test_slots1 ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edee90d0>, 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_slots1'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots1'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_slots1'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots1'>} 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_slots1'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots1'>} 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_slots1'>, '__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 0x7ff8eddfa5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots1'>, '__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 0x7ff8eddfa820> 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 0x7ff8eddfa820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots1'>, '__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_slots1'>, '__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 0x7ff8eddfa910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots1'>, '__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 0x7ff8eddfa9b0> 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 0x7ff8eddfa9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots1'>, '__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_slots1'>, '__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_slots1'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_slots1'> 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_slots1 at 0x7ff8ef1cfbd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8ede06990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd7f650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_slots1(): from types import ModuleType body = """ static PyModuleDef multiphase_def; static PyObject* multiphase_create(PyObject *spec, PyModuleDef *def) { PyObject *module = PyModule_New("altname"); PyObject_SetAttrString(module, "create_spec", spec); PyObject_SetAttrString(module, "create_def_eq", PyBool_FromLong(def == &multiphase_def)); return module; } static int multiphase_exec(PyObject* module) { Py_INCREF(Py_True); PyObject_SetAttrString(module, "exec_called", Py_True); return 0; } static PyModuleDef_Slot multiphase_slots[] = { {Py_mod_create, multiphase_create}, {Py_mod_exec, multiphase_exec}, {0, NULL} }; static PyModuleDef multiphase_def = { PyModuleDef_HEAD_INIT, /* m_base */ "multiphase", /* m_name */ "example docstring", /* m_doc */ 0, /* m_size */ NULL, /* m_methods */ multiphase_slots, /* m_slots */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL, /* m_free */ }; """ init = """ return PyModuleDef_Init(&multiphase_def); """ module = self.import_module(name='multiphase', body=body, init=init, use_imp=True) assert module.create_spec assert module.create_spec is module.__spec__ assert module.create_def_eq assert module.exec_called try: test_slots1() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestModuleObject.test_slots2 ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edfe91d0>, 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_slots2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots2'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_slots2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots2'>} 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_slots2'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_slots2'>} 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_slots2'>, '__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 0x7ff8ede1fd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots2'>, '__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 0x7ff8ede1f1e0> 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 0x7ff8ede1f1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots2'>, '__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_slots2'>, '__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 0x7ff8ede1f820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots2'>, '__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 0x7ff8ede1f910> 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 0x7ff8ede1f910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_slots2'>, '__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_slots2'>, '__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_slots2'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_slots2'> 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_slots2 at 0x7ff8ef1cfc50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8edde7750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edeef490> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_slots2(): from types import ModuleType body = """ static PyModuleDef multiphase_def; static PyObject* multiphase_create(PyObject *spec, PyModuleDef *def) { PyObject *name = PyUnicode_FromString("altname"); PyObject *module = PyModule_NewObject(name); Py_DECREF(name); PyObject_SetAttrString(module, "create_spec", spec); PyObject_SetAttrString(module, "create_def_eq", PyBool_FromLong(def == &multiphase_def)); return module; } static int multiphase_exec(PyObject* module) { Py_INCREF(Py_True); PyObject_SetAttrString(module, "exec_called", Py_True); return 0; } static PyModuleDef_Slot multiphase_slots[] = { {Py_mod_create, multiphase_create}, {Py_mod_exec, multiphase_exec}, {0, NULL} }; static PyModuleDef multiphase_def = { PyModuleDef_HEAD_INIT, /* m_base */ "multiphase", /* m_name */ "example docstring", /* m_doc */ 0, /* m_size */ NULL, /* m_methods */ multiphase_slots, /* m_slots */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL, /* m_free */ }; """ init = """ return PyModuleDef_Init(&multiphase_def); """ module = self.import_module(name='multiphase', body=body, init=init, use_imp=True) assert module.create_spec assert module.create_spec is module.__spec__ assert module.create_def_eq assert module.exec_called try: test_slots2() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestModuleObject.test_forget_init _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede75850>, 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_forget_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forget_init'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_forget_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forget_init'>} 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_forget_init'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_forget_init'>} 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_forget_init'>, '__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 0x7ff8edddc640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orget_init'>, '__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 0x7ff8ede7ea50> 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 0x7ff8ede7ea50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orget_init'>, '__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_forget_init'>, '__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 0x7ff8ef1d98c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orget_init'>, '__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 0x7ff8ede8a190> 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 0x7ff8ede8a190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...orget_init'>, '__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_forget_init'>, '__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_forget_init'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_forget_init'> 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_forget_init at 0x7ff8ef1cfcd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestModuleObject.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestM...eObject.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestModuleObject object at 0x7ff8edf00f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd7f7d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_forget_init(): from types import ModuleType body = """ static PyModuleDef multiphase_def = { PyModuleDef_HEAD_INIT, /* m_base */ "multiphase", /* m_name */ "example docstring", /* m_doc */ 0, /* m_size */ }; """ init = """ return (PyObject *) &multiphase_def; """ raises(SystemError, self.import_module, name='multiphase', body=body, init=init, use_imp=True) try: test_forget_init() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestMultiPhase.test__testmultiphase ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede6a6d0>, 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__testmultiphase'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test__testmultiphase'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test__testmultiphase'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test__testmultiphase'>} 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__testmultiphase'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test__testmultiphase'>} 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__testmultiphase'>, '__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 0x7ff8edd14730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...multiphase'>, '__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 0x7ff8edd147d0> 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 0x7ff8edd147d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...multiphase'>, '__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__testmultiphase'>, '__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 0x7ff8edd148c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...multiphase'>, '__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 0x7ff8edd14a00> 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 0x7ff8edd14a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...multiphase'>, '__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__testmultiphase'>, '__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__testmultiphase'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test__testmultiphase'> 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__testmultiphase at 0x7ff8ef1cfdd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edd7f190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd7f590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test__testmultiphase(): import sys from importlib import machinery, util module = self.import_module(name=self.name, use_imp=True) finder = machinery.FileFinder(None) spec = util.find_spec(self.name) assert spec assert module.__name__ == self.name #assert module.__file__ == spec.origin assert module.__package__ == '' raises(AttributeError, 'module.__path__') assert module is sys.modules[self.name] assert isinstance(module.__loader__, machinery.ExtensionFileLoader) try: test__testmultiphase() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestMultiPhase.test_functionality _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eded62d0>, 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_functionality'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_functionality'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_functionality'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_functionality'>} 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_functionality'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_functionality'>} 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_functionality'>, '__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 0x7ff8edd6b500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctionality'>, '__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 0x7ff8edd730f0> 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 0x7ff8edd730f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctionality'>, '__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_functionality'>, '__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 0x7ff8ede33780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctionality'>, '__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 0x7ff8ede33140> 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 0x7ff8ede33140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ctionality'>, '__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_functionality'>, '__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_functionality'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_functionality'> 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_functionality at 0x7ff8ef1cfe50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edde7090>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edde71d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_functionality(): import types module = self.import_module(name=self.name, use_imp=True) assert isinstance(module, types.ModuleType) ex = module.Example() assert ex.demo('abcd') == 'abcd' assert ex.demo() is None raises(AttributeError, 'ex.abc') ex.abc = 0 assert ex.abc == 0 assert module.foo(9, 9) == 18 assert isinstance(module.Str(), str) assert module.Str(1) + '23' == '123' raises(module.error, 'raise module.error()') assert module.int_const == 1969 assert module.str_const == 'something different' try: test_functionality() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestMultiPhase.test_reload _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede1c450>, 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_reload'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_reload'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_reload'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_reload'>} 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_reload'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_reload'>} 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_reload'>, '__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 0x7ff8edd14d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_reload'>, '__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 0x7ff8edd14be0> 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 0x7ff8edd14be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_reload'>, '__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_reload'>, '__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 0x7ff8edd14730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_reload'>, '__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 0x7ff8edd14f50> 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 0x7ff8edd14f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_reload'>, '__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_reload'>, '__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_reload'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_reload'> 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_reload at 0x7ff8ef1cfed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edde5150>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edde5210> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_reload(): import importlib module = self.import_module(name=self.name, use_imp=True) ex_class = module.Example # Simulate what importlib.reload() does, without recomputing the spec module.__spec__.loader.exec_module(module) assert ex_class is module.Example try: test_reload() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestMultiPhase.test_try_registration ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede1c350>, 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_try_registration'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_try_registration'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_try_registration'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_try_registration'>} 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_try_registration'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_try_registration'>} 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_try_registration'>, '__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 0x7ff8edccf4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gistration'>, '__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 0x7ff8edccf5a0> 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 0x7ff8edccf5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gistration'>, '__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_try_registration'>, '__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 0x7ff8edccf640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gistration'>, '__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 0x7ff8edccf730> 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 0x7ff8edccf730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...gistration'>, '__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_try_registration'>, '__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_try_registration'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_try_registration'> 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_try_registration at 0x7ff8ef1cff50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edde7150>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddf4150> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_try_registration(): module = self.import_module(name=self.name, use_imp=True) assert module.call_state_registration_func(0) is None with raises(SystemError): module.call_state_registration_func(1) with raises(SystemError): module.call_state_registration_func(2) try: test_try_registration() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestMultiPhase.test_bad_modules ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede1c450>, 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_bad_modules'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bad_modules'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_bad_modules'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bad_modules'>} 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_bad_modules'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_bad_modules'>} 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_bad_modules'>, '__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 0x7ff8edd17fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_modules'>, '__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 0x7ff8edd17dc0> 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 0x7ff8edd17dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_modules'>, '__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_bad_modules'>, '__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 0x7ff8edd17eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_modules'>, '__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 0x7ff8edd17d70> 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 0x7ff8edd17d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_modules'>, '__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_bad_modules'>, '__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_bad_modules'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_bad_modules'> 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_bad_modules at 0x7ff8ef1d00d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8ede06f90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edde7350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_bad_modules(): # XXX: not a very good test, since most internal issues in cpyext # cause SystemErrors. module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path for name in [ 'bad_slot_large', 'bad_slot_negative', 'create_int_with_state', 'negative_size', 'create_null', 'create_raise', 'create_unreported_exception', 'nonmodule_with_exec_slots', 'exec_err', 'exec_raise', 'exec_unreported_exception', ]: raises(SystemError, self.load_from_name, name, origin) try: test_bad_modules() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestMultiPhase.test_export_null ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede6a6d0>, 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_export_null'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_null'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_null'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_null'>} 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_export_null'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_null'>} 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_export_null'>, '__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 0x7ff8edcdb780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...xport_null'>, '__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 0x7ff8edcdba00> 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 0x7ff8edcdba00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...xport_null'>, '__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_export_null'>, '__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 0x7ff8edcdbaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...xport_null'>, '__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 0x7ff8edcdbb90> 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 0x7ff8edcdbb90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...xport_null'>, '__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_export_null'>, '__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_export_null'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_null'> 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_export_null at 0x7ff8ef1d0150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8ede069d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd1c690> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_null(): excinfo = raises(SystemError, self.load_from_name, 'export_null') assert "initialization" in excinfo.value.args[0] assert "without raising" in excinfo.value.args[0] try: test_export_null() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestMultiPhase.test_export_uninit _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede6b0d0>, 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_export_uninit'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_uninit'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_uninit'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_uninit'>} 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_export_uninit'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_uninit'>} 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_export_uninit'>, '__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 0x7ff8edcff460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ort_uninit'>, '__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 0x7ff8edcff5a0> 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 0x7ff8edcff5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ort_uninit'>, '__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_export_uninit'>, '__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 0x7ff8edcff640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ort_uninit'>, '__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 0x7ff8edcff730> 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 0x7ff8edcff730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ort_uninit'>, '__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_export_uninit'>, '__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_export_uninit'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_uninit'> 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_export_uninit at 0x7ff8ef1d01d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edde5650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edde5a50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_uninit(): excinfo = raises(SystemError, self.load_from_name, 'export_uninitialized') assert "init function" in excinfo.value.args[0] assert "uninitialized object" in excinfo.value.args[0] try: test_export_uninit() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestMultiPhase.test_export_raise ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcf7bd0>, 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_export_raise'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_raise'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_raise'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_raise'>} 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_export_raise'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_raise'>} 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_export_raise'>, '__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 0x7ff8edce1960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_raise'>, '__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 0x7ff8edce1a50> 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 0x7ff8edce1a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_raise'>, '__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_export_raise'>, '__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 0x7ff8edce1af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_raise'>, '__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 0x7ff8edce1be0> 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 0x7ff8edce1be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...port_raise'>, '__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_export_raise'>, '__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_export_raise'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_raise'> 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_export_raise at 0x7ff8ef1d0250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edd3fd50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd3f9d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_raise(): excinfo = raises(SystemError, self.load_from_name, 'export_raise') assert "bad export function" == excinfo.value.args[0] try: test_export_raise() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestMultiPhase.test_export_unreported ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edfeef50>, 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_export_unreported'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_unreported'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_export_unreported'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_unreported'>} 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_export_unreported'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_export_unreported'>} 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_export_unreported'>, '__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 0x7ff8ef351eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unreported'>, '__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 0x7ff8edfefc80> 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 0x7ff8edfefc80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unreported'>, '__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_export_unreported'>, '__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 0x7ff8edfef640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unreported'>, '__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 0x7ff8edccfc30> 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 0x7ff8edccfc30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...unreported'>, '__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_export_unreported'>, '__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_export_unreported'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_export_unreported'> 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_export_unreported at 0x7ff8ef1d02d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edd1c650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edde7350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_export_unreported(): excinfo = raises(SystemError, self.load_from_name, 'export_unreported_exception') assert "initialization" in excinfo.value.args[0] assert "unreported exception" in excinfo.value.args[0] try: test_export_unreported() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestMultiPhase.test_unloadable_nonascii __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: AssertionError > func = <function <lambda> at 0x7ff8edeb5050>, 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_unloadable_nonascii'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unloadable_nonascii'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_unloadable_nonascii'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unloadable_nonascii'>} 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_unloadable_nonascii'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_unloadable_nonascii'>} 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_unloadable_nonascii'>, '__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 0x7ff8edce1be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_nonascii'>, '__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 0x7ff8edce1af0> 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 0x7ff8edce1af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_nonascii'>, '__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_unloadable_nonascii'>, '__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 0x7ff8edce11e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_nonascii'>, '__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 0x7ff8edce1f00> 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 0x7ff8edce1f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...e_nonascii'>, '__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_unloadable_nonascii'>, '__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_unloadable_nonascii'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_unloadable_nonascii'> 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_unloadable_nonascii at 0x7ff8ef1d0350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edde5d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd1c850> 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 AssertionError 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_unloadable_nonascii(): name = u"fo\xf3" excinfo = raises(ImportError, self.load_from_name, name) assert excinfo.value.name == '_testmultiphase_' + name try: test_unloadable_nonascii() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- AssertionError _______________________ AppTestMultiPhase.test_nonascii ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede8bdd0>, 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_nonascii'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nonascii'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_nonascii'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nonascii'>} 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_nonascii'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nonascii'>} 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_nonascii'>, '__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 0x7ff8edd8d7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_nonascii'>, '__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 0x7ff8edd8d8c0> 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 0x7ff8edd8d8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_nonascii'>, '__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_nonascii'>, '__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 0x7ff8edd8d960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_nonascii'>, '__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 0x7ff8edd8da50> 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 0x7ff8edd8da50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_nonascii'>, '__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_nonascii'>, '__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_nonascii'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_nonascii'> 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_nonascii at 0x7ff8ef1d03d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8edd3c410>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd3c650> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_nonascii(): module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path cases = [ ('_testmultiphase_zkou\u0161ka_na\u010dten\xed', 'Czech'), ('\uff3f\u30a4\u30f3\u30dd\u30fc\u30c8\u30c6\u30b9\u30c8', 'Japanese'), ] for name, lang in cases: module = self.load_from_name(name, origin=origin, use_prefix=False) assert module.__name__ == name assert module.__doc__ == "Module named in %s" % lang try: test_nonascii() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestMultiPhase.test_get_module _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede6a950>, 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_get_module'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_module'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_get_module'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_module'>} 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_get_module'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_get_module'>} 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_get_module'>, '__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 0x7ff8edcf8870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...get_module'>, '__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 0x7ff8edcf8fa0> 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 0x7ff8edcf8fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...get_module'>, '__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_get_module'>, '__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 0x7ff8edcf82d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...get_module'>, '__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 0x7ff8edcf8f50> 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 0x7ff8edcf8f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...get_module'>, '__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_get_module'>, '__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_get_module'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_get_module'> 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_get_module at 0x7ff8ef1d0450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8eddd8bd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddd8f50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_get_module(): module = self.load_from_name("meth_state_access") print("module", dir(module)) instance0 = module.StateAccessType() assert instance0.get_defining_module() == module try: test_get_module() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestMultiPhase.test_fromdefandspec _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcf7bd0>, 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_fromdefandspec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromdefandspec'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fromdefandspec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromdefandspec'>} 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_fromdefandspec'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fromdefandspec'>} 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_fromdefandspec'>, '__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 0x7ff8edeb6aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...defandspec'>, '__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 0x7ff8edcfad70> 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 0x7ff8edcfad70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...defandspec'>, '__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_fromdefandspec'>, '__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 0x7ff8edcfacd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...defandspec'>, '__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 0x7ff8edcfab90> 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 0x7ff8edcfab90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...defandspec'>, '__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_fromdefandspec'>, '__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_fromdefandspec'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fromdefandspec'> 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_fromdefandspec at 0x7ff8ef1d04d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestMultiPhase.w_compile_module of <pypy.module.cpyext.test.test_module.AppTestMul...ultiPhase.w_import_extension of <pypy.module.cpyext.test.test_module.AppTestMultiPhase object at 0x7ff8eddd8410>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edfc5190> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_from_name(self, name, origin=None, use_prefix=True): from importlib import machinery, util if not origin: module = self.import_module(name=self.name, use_imp=True) origin = module.__loader__.path if use_prefix: name = '_testmultiphase_' + name loader = machinery.ExtensionFileLoader(name, origin) spec = util.spec_from_loader(name, loader) module = util.module_from_spec(spec) loader.exec_module(module) return module type(self).load_from_name = w_load_from_name def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.name = '_testmultiphase' self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fromdefandspec(): import sys import warnings prologue = """ static struct PyModuleDef foo2moduledef = { PyModuleDef_HEAD_INIT, "foo2", /* m_name */ NULL, /* m_doc */ 0, /* m_size */ NULL /* m_methods */ }; """ module = self.import_extension("get_mod", [ ('fromdefandspec', "METH_O", """ return PyModule_FromDefAndSpec2(&foo2moduledef, args, 1013); """), ('fromdefandspec2', "METH_O", """ return PyModule_FromDefAndSpec2(&foo2moduledef, args, 2); """), ], prologue=prologue) class Spec: name = "foo2" spec = Spec() with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always", RuntimeWarning) foo2 = module.fromdefandspec2(spec) assert foo2.__name__ == "foo2" foo2 = module.fromdefandspec(spec) assert foo2.__name__ == "foo2" try: test_fromdefandspec() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestNamespace.test_simple _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edeeabd0>, 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_simple'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_simple'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_simple'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_simple'>} 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_simple'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_simple'>} 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_simple'>, '__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 0x7ff8edc70910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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 0x7ff8edc70a00> 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 0x7ff8edc70a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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_simple'>, '__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 0x7ff8edc70aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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 0x7ff8edc70b90> 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 0x7ff8edc70b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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_simple'>, '__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_simple'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_simple'> 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_simple at 0x7ff8ef1d0d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestNamespace.w_compile_module of <pypy.module.cpyext.test.test_namespaceobject.Ap...e.w_import_extension of <pypy.module.cpyext.test.test_namespaceobject.AppTestNamespace object at 0x7ff8eddbc310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddbc110> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_simple(): from types import SimpleNamespace module = self.import_extension('ns', [ ("new", "METH_O", """ return _PyNamespace_New(args); """)]) assert module.new({'a': 1, 'b': 2}) == SimpleNamespace(a=1, b=2) try: test_simple() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestCNumber.test_Check ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eddf8850>, 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_Check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Check'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Check'>} 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_Check'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Check'>} 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_Check'>, '__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 0x7ff8ede9c1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Check'>, '__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 0x7ff8ede9c280> 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 0x7ff8ede9c280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Check'>, '__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_Check'>, '__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 0x7ff8ede9c550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Check'>, '__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 0x7ff8ede9cf00> 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 0x7ff8ede9cf00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Check'>, '__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_Check'>, '__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_Check'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Check'> 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_Check at 0x7ff8eef41250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCNumber.w_compile_module of <pypy.module.cpyext.test.test_number.AppTestCNumbe...pTestCNumber.w_import_extension of <pypy.module.cpyext.test.test_number.AppTestCNumber object at 0x7ff8edfc5d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edfc5ad0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Check(): import sys mod = self.import_extension('foo', [ ("PyNumber_Check", "METH_O", ''' int val = PyNumber_Check(args); return PyLong_FromLong(val); '''), ("PyIndex_Check", "METH_O", ''' int val = PyIndex_Check(args); return PyLong_FromLong(val); '''), ]) if 0: val = mod.PyNumber_Check(10) assert val == 1 assert mod.PyIndex_Check(12) assert mod.PyIndex_Check(-12) assert not mod.PyIndex_Check(12.1) assert not mod.PyIndex_Check('12') assert not mod.PyIndex_Check(1 + 3j) assert mod.PyNumber_Check(12) assert mod.PyNumber_Check(-12) assert mod.PyNumber_Check(12.1) assert not mod.PyNumber_Check('12') assert mod.PyNumber_Check(1 + 3j) # class MyIndex: def __index__(self): return 42 val = mod.PyNumber_Check(MyIndex()) assert val == 1 # issue 3383: CPython only checks for the presence of __index__, # not that it is valid class Raises: def __index__(self): raise ValueError(42) class Missing: pass m = Raises() assert mod.PyIndex_Check(m) m = Missing() assert not mod.PyIndex_Check(m) try: test_Check() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestCNumber.test_number_tobase _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eddf2250>, 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_number_tobase'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_number_tobase'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_number_tobase'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_number_tobase'>} 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_number_tobase'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_number_tobase'>} 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_number_tobase'>, '__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 0x7ff8edc067d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ber_tobase'>, '__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 0x7ff8edc068c0> 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 0x7ff8edc068c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ber_tobase'>, '__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_number_tobase'>, '__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 0x7ff8edc06960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ber_tobase'>, '__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 0x7ff8edc06a50> 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 0x7ff8edc06a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ber_tobase'>, '__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_number_tobase'>, '__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_number_tobase'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_number_tobase'> 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_number_tobase at 0x7ff8eef412d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCNumber.w_compile_module of <pypy.module.cpyext.test.test_number.AppTestCNumbe...pTestCNumber.w_import_extension of <pypy.module.cpyext.test.test_number.AppTestCNumber object at 0x7ff8edfc5f90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddbc510> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_number_tobase(): import sys mod = self.import_extension('foo', [ ("pynumber_tobase", "METH_VARARGS", """ PyObject *obj; int base; if (!PyArg_ParseTuple(args, "Oi:pynumber_tobase", &obj, &base)) { return NULL; } return PyNumber_ToBase(obj, base); """)]) assert mod.pynumber_tobase(123, 2) == '0b1111011' assert mod.pynumber_tobase(123, 8) == '0o173' assert mod.pynumber_tobase(123, 10) == '123' assert mod.pynumber_tobase(123, 16) == '0x7b' assert mod.pynumber_tobase(-123, 2) == '-0b1111011' assert mod.pynumber_tobase(-123, 8) == '-0o173' assert mod.pynumber_tobase(-123, 10) == '-123' assert mod.pynumber_tobase(-123, 16) == '-0x7b' try: mod.pynumber_tobase(123.0, 10) except TypeError: pass else: assert False, 'expected TypeError' try: mod.pynumber_tobase('123', 10) except TypeError: pass else: assert False, 'expected TypeError' if 'PyPy' in sys.version or sys.version_info >= (3,7): # bpo 38643 try: mod.pynumber_tobase(123, 0) except SystemError: pass else: assert False, 'expected TypeError' # large number: num = 2**66 assert mod.pynumber_tobase(num, 2) == '0b1' + '0' * 66 assert mod.pynumber_tobase(num, 8) == '0o10000000000000000000000' assert mod.pynumber_tobase(num, 10) == str(num) assert mod.pynumber_tobase(num, 16) == '0x40000000000000000' try: test_number_tobase() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestCNumber.test_number_to_ssize_t _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edebd350>, 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_number_to_ssize_t'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_number_to_ssize_t'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_number_to_ssize_t'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_number_to_ssize_t'>} 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_number_to_ssize_t'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_number_to_ssize_t'>} 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_number_to_ssize_t'>, '__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 0x7ff8edebbfa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...to_ssize_t'>, '__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 0x7ff8edebbd20> 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 0x7ff8edebbd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...to_ssize_t'>, '__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_number_to_ssize_t'>, '__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 0x7ff8edebbcd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...to_ssize_t'>, '__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 0x7ff8edebb3c0> 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 0x7ff8edebb3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...to_ssize_t'>, '__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_number_to_ssize_t'>, '__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_number_to_ssize_t'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_number_to_ssize_t'> 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_number_to_ssize_t at 0x7ff8eef41350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestCNumber.w_compile_module of <pypy.module.cpyext.test.test_number.AppTestCNumbe...pTestCNumber.w_import_extension of <pypy.module.cpyext.test.test_number.AppTestCNumber object at 0x7ff8edcddf90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddbc590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_number_to_ssize_t(): import sys mod = self.import_extension('foo', [ ("to_ssize_t", "METH_VARARGS", """ PyObject *obj; PyObject *exc = NULL; long long value; if (!PyArg_ParseTuple(args, "O|O:to_ssize_t", &obj, &exc)) { return NULL; } if (exc == NULL) { // printf("got no exc\\n"); } else { // printf("got exc\\n"); } value = PyNumber_AsSsize_t(obj, exc); if (PyErr_Occurred()) { return NULL; } return PyLong_FromLongLong(value); """)]) assert mod.to_ssize_t(2 ** 68) == sys.maxsize assert mod.to_ssize_t(12) == 12 raises(TypeError, mod.to_ssize_t, 2 ** 68, TypeError) try: test_number_to_ssize_t() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestObject.test_object_malloc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf886d0>, 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_object_malloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_malloc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_object_malloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_malloc'>} 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_object_malloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_malloc'>} 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_object_malloc'>, '__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 0x7ff8edc7caa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_malloc'>, '__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 0x7ff8edc7cb90> 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 0x7ff8edc7cb90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_malloc'>, '__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_object_malloc'>, '__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 0x7ff8edc7ce60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_malloc'>, '__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 0x7ff8edc7cd20> 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 0x7ff8edc7cd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_malloc'>, '__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_object_malloc'>, '__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_object_malloc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_object_malloc'> 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_object_malloc at 0x7ff8eed5e950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edfc5350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddbcc10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_object_malloc(): module = self.import_extension('foo', [ ("malloctest", "METH_NOARGS", """ PyObject *obj = PyObject_MALLOC(sizeof(PyFloatObject)); obj = PyObject_Init(obj, &PyFloat_Type); if (obj != NULL) ((PyFloatObject *)obj)->ob_fval = -12.34; return obj; """)]) x = module.malloctest() assert type(x) is float assert x == -12.34 try: test_object_malloc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestObject.test_object_calloc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd61150>, 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_object_calloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_calloc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_object_calloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_calloc'>} 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_object_calloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_calloc'>} 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_object_calloc'>, '__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 0x7ff8edc80870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_calloc'>, '__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 0x7ff8edd89fa0> 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 0x7ff8edd89fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_calloc'>, '__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_object_calloc'>, '__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 0x7ff8edc7c1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_calloc'>, '__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 0x7ff8edebbfa0> 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 0x7ff8edebbfa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ect_calloc'>, '__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_object_calloc'>, '__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_object_calloc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_object_calloc'> 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_object_calloc at 0x7ff8eed5e9d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edcfb750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edcfb550> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_object_calloc(): module = self.import_extension('foo', [ ("calloctest", "METH_NOARGS", """ PyObject *obj = PyObject_Calloc(1, sizeof(PyFloatObject)); if (obj == NULL) return NULL; obj = PyObject_Init(obj, &PyFloat_Type); return obj; """)]) x = module.calloctest() assert type(x) is float assert x == 0.0 try: test_object_calloc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestObject.test_object_realloc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf887d0>, 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_object_realloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_realloc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_object_realloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_realloc'>} 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_object_realloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_object_realloc'>} 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_object_realloc'>, '__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 0x7ff8edc17af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct_realloc'>, '__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 0x7ff8edc17b90> 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 0x7ff8edc17b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct_realloc'>, '__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_object_realloc'>, '__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 0x7ff8edc17c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct_realloc'>, '__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 0x7ff8edc17be0> 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 0x7ff8edc17be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct_realloc'>, '__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_object_realloc'>, '__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_object_realloc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_object_realloc'> 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_object_realloc at 0x7ff8eed5ea50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edfc5990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edfc5290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_object_realloc(): if not self.runappdirect: skip('no untranslated support for realloc') module = self.import_extension('foo', [ ("realloctest", "METH_NOARGS", """ PyObject * ret; char *copy, *orig = PyObject_MALLOC(12); memcpy(orig, "hello world", 12); copy = PyObject_REALLOC(orig, 15); /* realloc() takes care of freeing orig, if changed */ if (copy == NULL) Py_RETURN_NONE; ret = PyBytes_FromStringAndSize(copy, 12); PyObject_Free(copy); return ret; """)]) x = module.realloctest() assert x == b'hello world\x00' try: test_object_realloc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestObject.test_TypeCheck _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede2a650>, 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_TypeCheck'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_TypeCheck'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_TypeCheck'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_TypeCheck'>} 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_TypeCheck'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_TypeCheck'>} 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_TypeCheck'>, '__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 0x7ff8edc226e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._TypeCheck'>, '__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 0x7ff8edc22780> 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 0x7ff8edc22780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._TypeCheck'>, '__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_TypeCheck'>, '__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 0x7ff8edc22870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._TypeCheck'>, '__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 0x7ff8edc227d0> 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 0x7ff8edc227d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._TypeCheck'>, '__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_TypeCheck'>, '__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_TypeCheck'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_TypeCheck'> 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_TypeCheck at 0x7ff8eed5ead0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edfc5150>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edcfb850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_TypeCheck(): module = self.import_extension('foo', [ ("typecheck", "METH_VARARGS", """ PyObject *obj = PyTuple_GET_ITEM(args, 0); PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 1); return PyBool_FromLong(PyObject_TypeCheck(obj, type)); """)]) assert module.typecheck(1, int) assert module.typecheck('foo', str) assert module.typecheck('foo', object) assert module.typecheck(True, bool) assert module.typecheck(1.2, float) assert module.typecheck(int, type) try: test_TypeCheck() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________________ AppTestObject.test_print ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd78f50>, 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_print'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_print'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_print'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_print'>} 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_print'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_print'>} 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_print'>, '__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 0x7ff8edd5b0f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_print'>, '__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 0x7ff8edda4820> 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 0x7ff8edda4820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_print'>, '__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_print'>, '__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 0x7ff8edda4d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_print'>, '__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 0x7ff8edda4e10> 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 0x7ff8edda4e10> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_print'>, '__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_print'>, '__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_print'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_print'> 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_print at 0x7ff8eed5eb50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edfc5290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc45350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_print(): module = self.import_extension('foo', [ ("dump", "METH_VARARGS", """ PyObject *fname = PyTuple_GetItem(args, 0); PyObject *obj = PyTuple_GetItem(args, 1); FILE *fp = fopen(_PyUnicode_AsString(fname), "wb"); int ret; if (fp == NULL) Py_RETURN_NONE; ret = PyObject_Print(obj, fp, Py_PRINT_RAW); if (ret < 0) { fclose(fp); return NULL; } ret = PyObject_Print(NULL, fp, Py_PRINT_RAW); if (ret < 0) { fclose(fp); return NULL; } fclose(fp); Py_RETURN_TRUE; """), ("print_empty", "METH_O", """ FILE *fp = fopen(_PyUnicode_AsString(args), "wb"); if (fp == NULL) Py_RETURN_NONE; PyObject *obj = PyUnicode_FromStringAndSize(NULL, 0); int ret = PyObject_Print(obj, fp, 0); fclose(fp); if (ret < 0) { return NULL; } Py_RETURN_TRUE; """)]) assert module.dump(self.tmpname, None) result = '' with open(self.tmpname) as fid: result = fid.read() assert result == 'None<nil>' assert module.print_empty(self.tmpname) with open(self.tmpname) as fid: result = fid.read() # print("result=", result, len(result)) assert result == "''" try: test_print() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestObject.test_isinstance _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd1dad0>, 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_isinstance'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_isinstance'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_isinstance'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_isinstance'>} 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_isinstance'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_isinstance'>} 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_isinstance'>, '__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 0x7ff8edc80870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...isinstance'>, '__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 0x7ff8edc80b40> 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 0x7ff8edc80b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...isinstance'>, '__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_isinstance'>, '__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 0x7ff8edc80820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...isinstance'>, '__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 0x7ff8edc80730> 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 0x7ff8edc80730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...isinstance'>, '__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_isinstance'>, '__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_isinstance'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_isinstance'> 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_isinstance at 0x7ff8eed5ebd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edfc52d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddbc5d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_isinstance(): module = self.import_extension('foo', [ ("ismapping", "METH_O", """ PyObject* collections_mod = PyImport_ImportModule("collections.abc"); if (collections_mod == NULL) { return NULL; } PyObject* mapping_t = PyObject_GetAttrString( collections_mod, "Mapping"); Py_DECREF(collections_mod); if (mapping_t == NULL) { return NULL; } if (PyObject_IsInstance(args, mapping_t)) { Py_DECREF(mapping_t); Py_RETURN_TRUE; } else { Py_DECREF(mapping_t); Py_RETURN_FALSE; } """), ("is_function", "METH_O", """ if (PyObject_IsInstance(args, (PyObject *)&PyFunction_Type)) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } """),]) import collections.abc assert isinstance(dict(), collections.abc.Mapping) assert module.ismapping(dict()) def f(): pass assert not module.is_function(1) assert module.is_function(f) try: test_isinstance() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestObject.test_format_returns_unicode ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd61150>, 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_format_returns_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_format_returns_unicode'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_format_returns_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_format_returns_unicode'>} 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_format_returns_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_format_returns_unicode'>} 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_format_returns_unicode'>, '__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 0x7ff8eddcef50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ns_unicode'>, '__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 0x7ff8ede11780> 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 0x7ff8ede11780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ns_unicode'>, '__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_format_returns_unicode'>, '__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 0x7ff8ede11730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ns_unicode'>, '__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 0x7ff8ede116e0> 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 0x7ff8ede116e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ns_unicode'>, '__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_format_returns_unicode'>, '__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_format_returns_unicode'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_format_returns_unicode'> 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_format_returns_unicode at 0x7ff8eed5ec50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edd12590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd12bd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_format_returns_unicode(): module = self.import_extension('foo', [ ("empty_format", "METH_O", """ PyObject* empty_unicode = PyUnicode_FromStringAndSize("", 0); PyObject* obj = PyObject_Format(args, empty_unicode); return obj; """)]) a = module.empty_format('hello') assert isinstance(a, str) a = module.empty_format(type('hello')) assert isinstance(a, str) try: test_format_returns_unicode() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________________ AppTestObject.test_Bytes ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd1dad0>, 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_Bytes'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Bytes'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Bytes'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Bytes'>} 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_Bytes'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Bytes'>} 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_Bytes'>, '__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 0x7ff8edc068c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Bytes'>, '__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 0x7ff8edc067d0> 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 0x7ff8edc067d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Bytes'>, '__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_Bytes'>, '__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 0x7ff8edc064b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Bytes'>, '__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 0x7ff8edc061e0> 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 0x7ff8edc061e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Bytes'>, '__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_Bytes'>, '__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_Bytes'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Bytes'> 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_Bytes at 0x7ff8eed5ecd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8eddea250>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddea350> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_Bytes(): class sub1(bytes): pass class sub2(bytes): def __bytes__(self): return self module = self.import_extension('test_Bytes', [ ('asbytes', 'METH_O', """ return PyObject_Bytes(args); """)]) assert type(module.asbytes(sub1(b''))) is bytes assert type(module.asbytes(sub2(b''))) is sub2 assert module.asbytes(list(b"a")) == b"a" try: test_Bytes() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestObject.test_LengthHint _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ede2a650>, 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_LengthHint'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_LengthHint'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_LengthHint'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_LengthHint'>} 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_LengthHint'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_LengthHint'>} 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_LengthHint'>, '__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 0x7ff8edbee3c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...LengthHint'>, '__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 0x7ff8edbee4b0> 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 0x7ff8edbee4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...LengthHint'>, '__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_LengthHint'>, '__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 0x7ff8edbee550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...LengthHint'>, '__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 0x7ff8edbee640> 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 0x7ff8edbee640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...LengthHint'>, '__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_LengthHint'>, '__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_LengthHint'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_LengthHint'> 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_LengthHint at 0x7ff8eed5ed50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8eddea110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd12410> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_LengthHint(): import operator class WithLen: def __len__(self): return 1 def __length_hint__(self): return 42 class NoLen: def __length_hint__(self): return 2 module = self.import_extension('test_LengthHint', [ ('length_hint', 'METH_VARARGS', """ PyObject *obj = PyTuple_GET_ITEM(args, 0); Py_ssize_t i = PyLong_AsSsize_t(PyTuple_GET_ITEM(args, 1)); return PyLong_FromSsize_t(PyObject_LengthHint(obj, i)); """)]) assert module.length_hint(WithLen(), 5) == operator.length_hint(WithLen(), 5) == 1 assert module.length_hint(NoLen(), 5) == operator.length_hint(NoLen(), 5) == 2 assert module.length_hint(object(), 5) == operator.length_hint(object(), 5) == 5 try: test_LengthHint() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestObject.test_repr_enter_leave ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf88850>, 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_repr_enter_leave'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_enter_leave'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_repr_enter_leave'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_enter_leave'>} 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_repr_enter_leave'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_repr_enter_leave'>} 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_repr_enter_leave'>, '__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 0x7ff8edbeedc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nter_leave'>, '__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 0x7ff8edbee280> 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 0x7ff8edbee280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nter_leave'>, '__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_repr_enter_leave'>, '__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 0x7ff8edbee820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nter_leave'>, '__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 0x7ff8edbee140> 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 0x7ff8edbee140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nter_leave'>, '__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_repr_enter_leave'>, '__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_repr_enter_leave'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_repr_enter_leave'> 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_repr_enter_leave at 0x7ff8eed5ee50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edbeb110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbeb310> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_repr_enter_leave(): module = self.import_extension('foo', [ ("enter", "METH_O", """ return PyLong_FromLong(Py_ReprEnter(args)); """), ("leave", "METH_O", """ Py_ReprLeave(args); Py_INCREF(Py_None); return Py_None; """)]) obj1 = [42] obj2 = [42] # another list n = module.enter(obj1) assert n == 0 module.leave(obj1) n = module.enter(obj1) assert n == 0 n = module.enter(obj1) assert n == 1 n = module.enter(obj1) assert n == 1 module.leave(obj1) n = module.enter(obj1) assert n == 0 n = module.enter(obj2) assert n == 0 n = module.enter(obj1) assert n == 1 n = module.enter(obj2) assert n == 1 module.leave(obj1) n = module.enter(obj2) assert n == 1 module.leave(obj2) try: test_repr_enter_leave() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestObject.test_GenericGetSetDict _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcdf0d0>, 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_GenericGetSetDict'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_GenericGetSetDict'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_GenericGetSetDict'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_GenericGetSetDict'>} 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_GenericGetSetDict'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_GenericGetSetDict'>} 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_GenericGetSetDict'>, '__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 0x7ff8edbeecd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...GetSetDict'>, '__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 0x7ff8edbeeb90> 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 0x7ff8edbeeb90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...GetSetDict'>, '__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_GenericGetSetDict'>, '__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 0x7ff8edbee320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...GetSetDict'>, '__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 0x7ff8edebb910> 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 0x7ff8edebb910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...GetSetDict'>, '__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_GenericGetSetDict'>, '__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_GenericGetSetDict'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_GenericGetSetDict'> 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_GenericGetSetDict at 0x7ff8eed5eed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edbcb110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbcb050> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_GenericGetSetDict(): module = self.import_extension('test_GenericGetSetDict', [ ('test1', 'METH_VARARGS', """ PyObject *obj = PyTuple_GET_ITEM(args, 0); PyObject *newdict = PyTuple_GET_ITEM(args, 1); PyObject *olddict = PyObject_GenericGetDict(obj, NULL); if (olddict == NULL) return NULL; int res = PyObject_GenericSetDict(obj, newdict, NULL); if (res != 0) return NULL; return olddict; """)]) class A: pass a = A() a.x = 42 nd = {'y': 43} d = module.test1(a, nd) assert d == {'x': 42} assert a.y == 43 assert a.__dict__ is nd try: test_GenericGetSetDict() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________________ AppTestObject.test_Py_Is ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edced6d0>, 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_Py_Is'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_Is'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Py_Is'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_Is'>} 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_Py_Is'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Py_Is'>} 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_Py_Is'>, '__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 0x7ff8edbaa5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_Is'>, '__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 0x7ff8edbaa7d0> 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 0x7ff8edbaa7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_Is'>, '__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_Py_Is'>, '__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 0x7ff8edbaa8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_Is'>, '__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 0x7ff8edbaa960> 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 0x7ff8edbaa960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_Py_Is'>, '__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_Py_Is'>, '__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_Py_Is'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Py_Is'> 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_Py_Is at 0x7ff8eed5ef50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edbcb990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbeb710> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_Py_Is(): module = self.import_extension('foo', [ ('test_is', 'METH_VARARGS', """ PyObject *obj1 = PyTuple_GET_ITEM(args, 0); PyObject *obj2 = PyTuple_GET_ITEM(args, 1); int res = Py_Is(obj1, obj2); return PyLong_FromLong(res); """)]) nan1 = float('nan') nan2 = float('nan') assert module.test_is(nan1, nan2) a = 1 b = 1 assert module.test_is(a, b) assert not module.test_is(a, nan1) try: test_Py_Is() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestObject.test_SetAttrNull ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcdf0d0>, 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_SetAttrNull'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetAttrNull'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetAttrNull'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetAttrNull'>} 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_SetAttrNull'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetAttrNull'>} 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_SetAttrNull'>, '__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 0x7ff8edbaad20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etAttrNull'>, '__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 0x7ff8edbaa460> 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 0x7ff8edbaa460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etAttrNull'>, '__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_SetAttrNull'>, '__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 0x7ff8edbaa280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etAttrNull'>, '__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 0x7ff8edbaa140> 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 0x7ff8edbaa140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...etAttrNull'>, '__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_SetAttrNull'>, '__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_SetAttrNull'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetAttrNull'> 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_SetAttrNull at 0x7ff8eed64050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTestObject ...AppTestObject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestObject object at 0x7ff8edc00f90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc00810> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module def _skip_test(*ignored): skip("not for -A testing") type(self).reset_memory_pressure = _skip_test self.runappdirect = True self.tmpname = '/tmp/pytest/pytest-of-buildslave/pytest-11226/out' self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetAttrNull(): module = self.import_extension('foo', [ ('set_attr_null', 'METH_VARARGS', """ PyObject *obj = PyTuple_GET_ITEM(args, 0); PyObject *name = PyTuple_GET_ITEM(args, 1); PyObject_SetAttr(obj, name, NULL); Py_RETURN_TRUE; """), ('set_test_null', 'METH_O', """ PyObject_SetAttrString(args, "test", NULL); Py_RETURN_TRUE; """), ]) class A(object): pass a = A() a.test = 20 module.set_attr_null(a, "test") assert not hasattr(a, "test") a.test = 20 module.set_test_null(a) assert not hasattr(a, "test") try: test_SetAttrNull() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestPyBufferObject.test_fillWithoutObject _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcf2650>, 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_fillWithoutObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithoutObject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fillWithoutObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithoutObject'>} 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_fillWithoutObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithoutObject'>} 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_fillWithoutObject'>, '__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 0x7ff8edbe3280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...houtObject'>, '__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 0x7ff8edbe3c30> 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 0x7ff8edbe3c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...houtObject'>, '__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_fillWithoutObject'>, '__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 0x7ff8edbe39b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...houtObject'>, '__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 0x7ff8edbe3500> 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 0x7ff8edbe3500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...houtObject'>, '__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_fillWithoutObject'>, '__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_fillWithoutObject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fillWithoutObject'> 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_fillWithoutObject at 0x7ff8eed640d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBufferObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestPyBufferObject object at 0x7ff8edc7ad50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc7a390> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fillWithoutObject(): """ PyBuffer_FillInfo populates the C{buf} and C{length}fields of the Py_buffer passed to it. """ module = self.import_extension('foo', [ ("fillinfo", "METH_NOARGS", """ Py_buffer buf; PyObject *str = PyBytes_FromString("hello, world."); PyObject *result; if (PyBuffer_FillInfo(&buf, NULL, PyBytes_AsString(str), 13, 0, 0)) { return NULL; } /* Check a few things we want to have happened. */ if (buf.buf != PyBytes_AsString(str)) { PyErr_SetString(PyExc_ValueError, "buf field not initialized"); return NULL; } if (buf.len != 13) { PyErr_SetString(PyExc_ValueError, "len field not initialized"); return NULL; } if (buf.obj != NULL) { PyErr_SetString(PyExc_ValueError, "obj field not initialized"); return NULL; } /* Give back a new string to the caller, constructed from data in the * Py_buffer. */ if (!(result = PyBytes_FromStringAndSize(buf.buf, buf.len))) { return NULL; } /* Free that string we allocated above. result does not share storage with * it. */ Py_DECREF(str); return result; """)]) result = module.fillinfo() assert b"hello, world." == result try: test_fillWithoutObject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestPyBufferObject.test_fillWithObject ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edf88850>, 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_fillWithObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithObject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fillWithObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithObject'>} 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_fillWithObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillWithObject'>} 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_fillWithObject'>, '__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 0x7ff8edba2410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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 0x7ff8edba25f0> 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 0x7ff8edba25f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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_fillWithObject'>, '__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 0x7ff8edba26e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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 0x7ff8edba2780> 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 0x7ff8edba2780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...WithObject'>, '__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_fillWithObject'>, '__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_fillWithObject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fillWithObject'> 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_fillWithObject at 0x7ff8eed64150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBufferObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestPyBufferObject object at 0x7ff8edbeb510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbebcd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fillWithObject(): """ PyBuffer_FillInfo populates the C{buf}, C{length}, and C{obj} fields of the Py_buffer passed to it and increments the reference count of the object. """ module = self.import_extension('foo', [ ("fillinfo", "METH_NOARGS", """ Py_buffer buf; PyObject *str = PyBytes_FromString("hello, world."); PyObject *result; if (PyBuffer_FillInfo(&buf, str, PyBytes_AsString(str), 13, 0, 0)) { return NULL; } /* Get rid of our own reference to the object, but the Py_buffer should * still have a reference. */ Py_DECREF(str); /* Give back a new string to the caller, constructed from data in the * Py_buffer. It better still be valid. */ if (!(result = PyBytes_FromStringAndSize(buf.buf, buf.len))) { return NULL; } /* Now the data in the Py_buffer is really no longer needed, get rid of it *(could use PyBuffer_Release here, but that would drag in more code than * necessary). */ Py_DECREF(buf.obj); /* Py_DECREF can't directly signal error to us, but if it makes a reference * count go negative, it will set an error. */ if (PyErr_Occurred()) { return NULL; } return result; """)]) result = module.fillinfo() assert b"hello, world." == result try: test_fillWithObject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestPyBufferObject.test_fillReadonly ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcf2650>, 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_fillReadonly'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillReadonly'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fillReadonly'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillReadonly'>} 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_fillReadonly'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fillReadonly'>} 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_fillReadonly'>, '__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 0x7ff8edfa7be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llReadonly'>, '__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 0x7ff8edce5eb0> 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 0x7ff8edce5eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llReadonly'>, '__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_fillReadonly'>, '__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 0x7ff8edce5e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llReadonly'>, '__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 0x7ff8edbab050> 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 0x7ff8edbab050> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...llReadonly'>, '__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_fillReadonly'>, '__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_fillReadonly'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fillReadonly'> 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_fillReadonly at 0x7ff8eed641d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBufferObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestPyBufferObject object at 0x7ff8edbc3550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eddbc5d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fillReadonly(): """ PyBuffer_FillInfo fails if WRITABLE is passed but object is readonly. """ module = self.import_extension('foo', [ ("fillinfo", "METH_NOARGS", """ Py_buffer buf; PyObject *str = PyBytes_FromString("hello, world."); if (PyBuffer_FillInfo(&buf, str, PyBytes_AsString(str), 13, 1, PyBUF_WRITABLE)) { Py_DECREF(str); return NULL; } Py_DECREF(str); PyBuffer_Release(&buf); Py_RETURN_NONE; """)]) raises((BufferError, ValueError), module.fillinfo) try: test_fillReadonly() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestPyBufferObject.test_decrefObject ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd8e550>, 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_decrefObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_decrefObject'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_decrefObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_decrefObject'>} 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_decrefObject'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_decrefObject'>} 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_decrefObject'>, '__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 0x7ff8edb3d6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...crefObject'>, '__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 0x7ff8edb3d7d0> 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 0x7ff8edb3d7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...crefObject'>, '__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_decrefObject'>, '__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 0x7ff8edb3d870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...crefObject'>, '__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 0x7ff8edb3d960> 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 0x7ff8edb3d960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...crefObject'>, '__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_decrefObject'>, '__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_decrefObject'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_decrefObject'> 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_decrefObject at 0x7ff8eed64250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBufferObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestPyBufferObject object at 0x7ff8edb854d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb85290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_decrefObject(): """ The PyObject referenced by Py_buffer.obj has its reference count decremented by PyBuffer_Release. """ module = self.import_extension('foo', [ ("release", "METH_NOARGS", """ Py_buffer buf; buf.obj = PyBytes_FromString("release me!"); buf.buf = PyBytes_AsString(buf.obj); buf.len = PyBytes_Size(buf.obj); /* The Py_buffer owns the only reference to that string. Release the * Py_buffer and the string should be released as well. */ PyBuffer_Release(&buf); assert(!buf.obj); PyBuffer_Release(&buf); /* call again, should not have any more effect */ PyBuffer_Release(&buf); PyBuffer_Release(&buf); Py_RETURN_NONE; """)]) assert module.release() is None try: test_decrefObject() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestPyBufferObject.test_richcomp_nan ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd9f9d0>, 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_richcomp_nan'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_richcomp_nan'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_richcomp_nan'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_richcomp_nan'>} 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_richcomp_nan'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_richcomp_nan'>} 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_richcomp_nan'>, '__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 0x7ff8edbe7640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...chcomp_nan'>, '__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 0x7ff8edbe7690> 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 0x7ff8edbe7690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...chcomp_nan'>, '__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_richcomp_nan'>, '__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 0x7ff8edbe7af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...chcomp_nan'>, '__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 0x7ff8edbe7500> 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 0x7ff8edbe7500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...chcomp_nan'>, '__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_richcomp_nan'>, '__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_richcomp_nan'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_richcomp_nan'> 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_richcomp_nan at 0x7ff8eed642d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyBufferObject.w_compile_module of <pypy.module.cpyext.test.test_object.AppTes...bject.w_import_extension of <pypy.module.cpyext.test.test_object.AppTestPyBufferObject object at 0x7ff8edbb8790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbb8990> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_richcomp_nan(): module = self.import_extension('foo', [ ("comp_eq", "METH_VARARGS", """ PyObject *a = PyTuple_GetItem(args, 0); PyObject *b = PyTuple_GetItem(args, 1); int res = PyObject_RichCompareBool(a, b, Py_EQ); return PyLong_FromLong(res); """),]) a = float('nan') b = float('nan') assert a is b res = module.comp_eq(a, b) assert res == 1 try: test_richcomp_nan() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestFetch.test_occurred __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcd95d0>, 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_occurred'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_occurred'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_occurred'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_occurred'>} 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_occurred'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_occurred'>} 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_occurred'>, '__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 0x7ff8edba2d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_occurred'>, '__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 0x7ff8edba2e60> 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 0x7ff8edba2e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_occurred'>, '__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_occurred'>, '__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 0x7ff8edba2d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_occurred'>, '__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 0x7ff8edba2280> 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 0x7ff8edba2280> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_occurred'>, '__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_occurred'>, '__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_occurred'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_occurred'> 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_occurred at 0x7ff8eec97550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edb85350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb13b10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_occurred(): module = self.import_extension('foo', [ ("check_error", "METH_NOARGS", ''' PyErr_SetString(PyExc_TypeError, "message"); PyErr_Occurred(); PyErr_Clear(); Py_RETURN_TRUE; ''' ), ]) assert module.check_error() try: test_occurred() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestFetch.test_fetch_and_restore ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd8e7d0>, 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_fetch_and_restore'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fetch_and_restore'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fetch_and_restore'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fetch_and_restore'>} 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_fetch_and_restore'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fetch_and_restore'>} 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_fetch_and_restore'>, '__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 0x7ff8edcc0550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nd_restore'>, '__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 0x7ff8edcc0730> 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 0x7ff8edcc0730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nd_restore'>, '__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_fetch_and_restore'>, '__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 0x7ff8edcc0820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nd_restore'>, '__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 0x7ff8edcc08c0> 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 0x7ff8edcc08c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nd_restore'>, '__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_fetch_and_restore'>, '__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_fetch_and_restore'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fetch_and_restore'> 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_fetch_and_restore at 0x7ff8eec975d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edb13e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbb8950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_fetch_and_restore(): module = self.import_extension('foo', [ ("check_error", "METH_NOARGS", ''' PyObject *type, *val, *tb; PyErr_SetString(PyExc_TypeError, "message"); PyErr_Fetch(&type, &val, &tb); if (PyErr_Occurred()) return NULL; if (type != PyExc_TypeError) Py_RETURN_FALSE; PyErr_Restore(type, val, tb); if (!PyErr_Occurred()) Py_RETURN_FALSE; PyErr_Clear(); Py_RETURN_TRUE; ''' ), ]) assert module.check_error() try: test_fetch_and_restore() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestFetch.test_normalize __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcf2650>, 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_normalize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_normalize'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_normalize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_normalize'>} 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_normalize'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_normalize'>} 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_normalize'>, '__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 0x7ff8edc8a550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._normalize'>, '__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 0x7ff8edc8a5f0> 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 0x7ff8edc8a5f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._normalize'>, '__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_normalize'>, '__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 0x7ff8edc8a6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._normalize'>, '__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 0x7ff8edc8a640> 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 0x7ff8edc8a640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._normalize'>, '__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_normalize'>, '__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_normalize'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_normalize'> 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_normalize at 0x7ff8eec97650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edbb87d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbc91d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_normalize(): module = self.import_extension('foo', [ ("check_error", "METH_NOARGS", ''' PyObject *type, *val, *tb; PyErr_SetString(PyExc_TypeError, "message"); PyErr_Fetch(&type, &val, &tb); if (type != PyExc_TypeError) Py_RETURN_FALSE; if (!PyUnicode_Check(val)) Py_RETURN_FALSE; /* Normalize */ PyErr_NormalizeException(&type, &val, &tb); if (type != PyExc_TypeError) Py_RETURN_FALSE; if ((PyObject*)Py_TYPE(val) != PyExc_TypeError) Py_RETURN_FALSE; /* Normalize again */ PyErr_NormalizeException(&type, &val, &tb); if (type != PyExc_TypeError) Py_RETURN_FALSE; if ((PyObject*)Py_TYPE(val) != PyExc_TypeError) Py_RETURN_FALSE; PyErr_Restore(type, val, tb); PyErr_Clear(); Py_RETURN_TRUE; ''' ), ]) assert module.check_error() try: test_normalize() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestFetch.test_normalize_no_exception ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcdf0d0>, 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_normalize_no_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_normalize_no_exception'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_normalize_no_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_normalize_no_exception'>} 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_normalize_no_exception'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_normalize_no_exception'>} 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_normalize_no_exception'>, '__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 0x7ff8edcc0a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8edcc0410> 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 0x7ff8edcc0410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_normalize_no_exception'>, '__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 0x7ff8edcc08c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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 0x7ff8edcc0550> 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 0x7ff8edcc0550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._exception'>, '__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_normalize_no_exception'>, '__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_normalize_no_exception'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_normalize_no_exception'> 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_normalize_no_exception at 0x7ff8eec976d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edb13190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc7ab50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_normalize_no_exception(): module = self.import_extension('foo', [ ("check_error", "METH_NOARGS", ''' PyObject *type, *val, *tb; PyErr_Fetch(&type, &val, &tb); if (type != NULL) Py_RETURN_FALSE; if (val != NULL) Py_RETURN_FALSE; PyErr_NormalizeException(&type, &val, &tb); Py_RETURN_TRUE; ''' ), ]) assert module.check_error() try: test_normalize_no_exception() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestFetch.test_SetFromErrno ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd8e8d0>, 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_SetFromErrno'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrno'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrno'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrno'>} 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_SetFromErrno'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrno'>} 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_SetFromErrno'>, '__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 0x7ff8edc959b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tFromErrno'>, '__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 0x7ff8edc95aa0> 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 0x7ff8edc95aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tFromErrno'>, '__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_SetFromErrno'>, '__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 0x7ff8edc95b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tFromErrno'>, '__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 0x7ff8edc95c30> 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 0x7ff8edc95c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tFromErrno'>, '__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_SetFromErrno'>, '__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_SetFromErrno'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrno'> 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_SetFromErrno at 0x7ff8eec97750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edd98d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd98e90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrno(): import sys if not self.runappdirect: skip("callbacks through ll2ctypes modify errno") import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' errno = EBADF; PyErr_SetFromErrno(PyExc_OSError); return NULL; '''), ], prologue="#include <errno.h>") try: module.set_from_errno() except OSError as e: print(e.errno, errno.EBADF) assert e.errno == errno.EBADF assert e.strerror == os.strerror(errno.EBADF) assert e.filename is None try: test_SetFromErrno() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestFetch.test_SetFromErrnoWithFilename_basic _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc760d0>, 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_SetFromErrnoWithFilename_basic'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilename_basic'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilename_basic'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilename_basic'>} 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_SetFromErrnoWithFilename_basic'...all__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilename_basic'>} 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_SetFromErrnoWithFilename_basic'>, '__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 0x7ff8edc79dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...name_basic'>, '__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 0x7ff8edc8a1e0> 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 0x7ff8edc8a1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...name_basic'>, '__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_SetFromErrnoWithFilename_basic'>, '__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 0x7ff8edbe1fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...name_basic'>, '__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 0x7ff8edbbe500> 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 0x7ff8edbbe500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...name_basic'>, '__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_SetFromErrnoWithFilename_basic'>, '__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_SetFromErrnoWithFilename_basic'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilename_basic'> 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_SetFromErrnoWithFilename_basic at 0x7ff8eec977d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edd98590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc7ab90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilename_basic(): char = self.special_char if char is None: char = "a" # boring import errno, os, sys codestr = [ ("set_from_errno", "METH_NOARGS", ''' errno = EBADF; PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/path/to/file"); return NULL; '''), ("set_from_errno_special", "METH_NOARGS", ''' errno = EBADF; PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/path/to/%s"); return NULL; ''' % (char, )), ] if sys.platform == "win32": codestr += [ ("set_from_windowserr", "METH_NOARGS", """ /* this error code has no message, Python formats it as hexadecimal */ int code = 376526934; PyObject *ret = PyErr_SetFromWindowsErr(code); return NULL; """), ("set_from_windowserr_filename", "METH_O", """ int code = 376526934; char *filename = NULL; if (args != Py_None) filename = PyBytes_AsString(args); PyObject *ret = PyErr_SetFromWindowsErrWithFilename(code, filename); return NULL; """), ("set_from_windowserr_filename_object", "METH_O", """ int code = 376526934; PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, code, args); return NULL; """), ("set_from_windowserr_filename_objects", "METH_VARARGS", """ int code = 376526934; PyObject *arg1, *arg2; if (!PyArg_ParseTuple(args, "OO", &arg1, &arg2)) { return NULL; } PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObjects(PyExc_OSError, code, arg1, arg2); return NULL; """), ] module = self.import_extension('foo', codestr, prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename == "/path/to/file" if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) exc_info = raises(OSError, module.set_from_errno_special) assert exc_info.value.filename == "/path/to/%s" % (char, ) if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) if sys.platform == "win32": exc_info = raises(OSError, module.set_from_windowserr) if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == 376526934 exc_info = raises(OSError, module.set_from_windowserr_filename, None) if self.runappdirect: assert exc_info.value.errno == 376526934 exc_info = raises(OSError, module.set_from_windowserr_filename, b"myfile.py") if self.runappdirect: assert exc_info.value.errno == 376526934 assert exc_info.value.filename == "myfile.py" exc_info = raises(OSError, module.set_from_windowserr_filename_object, "myfile.py") print(exc_info.value.filename) if self.runappdirect: assert exc_info.value.errno == 376526934 assert exc_info.value.filename == "myfile.py" exc_info = raises(OSError, module.set_from_windowserr_filename_objects, "myfile.py", "myfile2.py") print(exc_info.value, exc_info.value.filename) if self.runappdirect: assert exc_info.value.errno == 376526934 assert exc_info.value.filename == "myfile.py" assert exc_info.value.filename2== "myfile2.py" try: test_SetFromErrnoWithFilename_basic() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________ AppTestFetch.test_SetFromErrnoWithFilename_NULL ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc39150>, 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_SetFromErrnoWithFilename_NULL'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilename_NULL'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilename_NULL'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilename_NULL'>} 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_SetFromErrnoWithFilename_NULL'>...call__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilename_NULL'>} 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_SetFromErrnoWithFilename_NULL'>, '__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 0x7ff8edbe7140> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ename_NULL'>, '__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 0x7ff8edbe7690> 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 0x7ff8edbe7690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ename_NULL'>, '__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_SetFromErrnoWithFilename_NULL'>, '__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 0x7ff8edbe7500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ename_NULL'>, '__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 0x7ff8edc8a6e0> 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 0x7ff8edc8a6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ename_NULL'>, '__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_SetFromErrnoWithFilename_NULL'>, '__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_SetFromErrnoWithFilename_NULL'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilename_NULL'> 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_SetFromErrnoWithFilename_NULL at 0x7ff8eec97850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edca3ed0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edbc9ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilename_NULL(): import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' errno = EBADF; PyErr_SetFromErrnoWithFilename(PyExc_OSError, NULL); return NULL; '''), ], prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename is None if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) try: test_SetFromErrnoWithFilename_NULL() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyUnicode __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc760d0>, 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_SetFromErrnoWithFilenameObject_...ultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyUnicode'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject_...ultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyUnicode'>} 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_SetFromErrnoWithFilenameObject_...ultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyUnicode'>} 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_SetFromErrnoWithFilenameObject__PyUnicode'>, '__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 0x7ff8edafa500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyUnicode'>, '__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 0x7ff8edafa6e0> 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 0x7ff8edafa6e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyUnicode'>, '__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_SetFromErrnoWithFilenameObject__PyUnicode'>, '__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 0x7ff8edafa7d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyUnicode'>, '__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 0x7ff8edafa870> 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 0x7ff8edafa870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._PyUnicode'>, '__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_SetFromErrnoWithFilenameObject__PyUnicode'>, '__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_SetFromErrnoWithFilenameObject__PyUnicode'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyUnicode'> 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_SetFromErrnoWithFilenameObject__PyUnicode at 0x7ff8eec978d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edcb6d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edcb6e10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilenameObject__PyUnicode(): import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' PyObject *filenameObject = PyUnicode_FromString("/path/to/file"); errno = EBADF; PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, filenameObject); Py_DECREF(filenameObject); return NULL; '''), ("set_from_errno2", "METH_NOARGS", ''' PyObject *filenameObject = PyUnicode_FromString("/path/to/file"); errno = EBADF; PyErr_SetFromErrnoWithFilenameObjects(PyExc_OSError, filenameObject, filenameObject); Py_DECREF(filenameObject); return NULL; '''), ], prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename == "/path/to/file" exc_info = raises(OSError, module.set_from_errno2) assert exc_info.value.filename == "/path/to/file" assert exc_info.value.filename2 == "/path/to/file" if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) try: test_SetFromErrnoWithFilenameObject__PyUnicode() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyLong ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc39150>, 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_SetFromErrnoWithFilenameObject_...<_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyLong'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject_...<_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyLong'>} 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_SetFromErrnoWithFilenameObject_...<_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyLong'>} 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_SetFromErrnoWithFilenameObject__PyLong'>, '__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 0x7ff8edaeb640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyLong'>, '__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 0x7ff8edaeb820> 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 0x7ff8edaeb820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyLong'>, '__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_SetFromErrnoWithFilenameObject__PyLong'>, '__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 0x7ff8edaeb910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyLong'>, '__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 0x7ff8edaeb9b0> 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 0x7ff8edaeb9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyLong'>, '__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_SetFromErrnoWithFilenameObject__PyLong'>, '__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_SetFromErrnoWithFilenameObject__PyLong'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyLong'> 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_SetFromErrnoWithFilenameObject__PyLong at 0x7ff8eec97950> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edcb6fd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb39e10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilenameObject__PyLong(): import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' PyObject *intObject = PyLong_FromLong(3); errno = EBADF; PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, intObject); Py_DECREF(intObject); return NULL; '''), ], prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename == 3 if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) try: test_SetFromErrnoWithFilenameObject__PyLong() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyList ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc760d0>, 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_SetFromErrnoWithFilenameObject_...<_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyList'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject_...<_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyList'>} 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_SetFromErrnoWithFilenameObject_...<_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyList'>} 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_SetFromErrnoWithFilenameObject__PyList'>, '__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 0x7ff8edbb5b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyList'>, '__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 0x7ff8edbb5c30> 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 0x7ff8edbb5c30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyList'>, '__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_SetFromErrnoWithFilenameObject__PyList'>, '__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 0x7ff8edbb5910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyList'>, '__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 0x7ff8edbb54b0> 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 0x7ff8edbb54b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ct__PyList'>, '__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_SetFromErrnoWithFilenameObject__PyList'>, '__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_SetFromErrnoWithFilenameObject__PyList'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyList'> 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_SetFromErrnoWithFilenameObject__PyList at 0x7ff8eec979d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edd98e50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd98fd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilenameObject__PyList(): import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' PyObject *lst = Py_BuildValue("[iis]", 1, 2, "three"); errno = EBADF; PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, lst); Py_DECREF(lst); return NULL; '''), ], prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename == [1, 2, "three"] if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) try: test_SetFromErrnoWithFilenameObject__PyList() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyTuple ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcdf0d0>, 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_SetFromErrnoWithFilenameObject_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyTuple'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyTuple'>} 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_SetFromErrnoWithFilenameObject_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyTuple'>} 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_SetFromErrnoWithFilenameObject__PyTuple'>, '__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 0x7ff8edae18c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__PyTuple'>, '__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 0x7ff8edae19b0> 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 0x7ff8edae19b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__PyTuple'>, '__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_SetFromErrnoWithFilenameObject__PyTuple'>, '__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 0x7ff8edae1a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__PyTuple'>, '__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 0x7ff8edae1b40> 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 0x7ff8edae1b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__PyTuple'>, '__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_SetFromErrnoWithFilenameObject__PyTuple'>, '__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_SetFromErrnoWithFilenameObject__PyTuple'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilenameObject__PyTuple'> 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_SetFromErrnoWithFilenameObject__PyTuple at 0x7ff8eec97a50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edd7be50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd7b890> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilenameObject__PyTuple(): import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' PyObject *tuple = Py_BuildValue("(iis)", 1, 2, "three"); errno = EBADF; PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, tuple); Py_DECREF(tuple); return NULL; '''), ], prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename == (1, 2, "three") if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) try: test_SetFromErrnoWithFilenameObject__PyTuple() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________ AppTestFetch.test_SetFromErrnoWithFilenameObject__Py_None ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcd9350>, 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_SetFromErrnoWithFilenameObject_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__Py_None'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__Py_None'>} 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_SetFromErrnoWithFilenameObject_..._MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_SetFromErrnoWithFilenameObject__Py_None'>} 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_SetFromErrnoWithFilenameObject__Py_None'>, '__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 0x7ff8edbb9820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__Py_None'>, '__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 0x7ff8edbb9370> 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 0x7ff8edbb9370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__Py_None'>, '__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_SetFromErrnoWithFilenameObject__Py_None'>, '__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 0x7ff8edbb98c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__Py_None'>, '__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 0x7ff8edc959b0> 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 0x7ff8edc959b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t__Py_None'>, '__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_SetFromErrnoWithFilenameObject__Py_None'>, '__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_SetFromErrnoWithFilenameObject__Py_None'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_SetFromErrnoWithFilenameObject__Py_None'> 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_SetFromErrnoWithFilenameObject__Py_None at 0x7ff8eec97ad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edcb6890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edd98910> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_SetFromErrnoWithFilenameObject__Py_None(): import errno, os module = self.import_extension('foo', [ ("set_from_errno", "METH_NOARGS", ''' PyObject *none = Py_BuildValue(""); errno = EBADF; PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, none); Py_DECREF(none); return NULL; '''), ], prologue="#include <errno.h>") exc_info = raises(OSError, module.set_from_errno) assert exc_info.value.filename is None if self.runappdirect: # untranslated the errno can get reset by the calls to ll2ctypes assert exc_info.value.errno == errno.EBADF assert exc_info.value.strerror == os.strerror(errno.EBADF) try: test_SetFromErrnoWithFilenameObject__Py_None() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestFetch.test_PyErr_Display ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd990d0>, 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_PyErr_Display'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_Display'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyErr_Display'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_Display'>} 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_PyErr_Display'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_Display'>} 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_PyErr_Display'>, '__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 0x7ff8edb48820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rr_Display'>, '__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 0x7ff8edb48a00> 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 0x7ff8edb48a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rr_Display'>, '__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_PyErr_Display'>, '__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 0x7ff8edb48af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rr_Display'>, '__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 0x7ff8edb48b90> 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 0x7ff8edb48b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...rr_Display'>, '__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_PyErr_Display'>, '__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_PyErr_Display'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyErr_Display'> 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_PyErr_Display at 0x7ff8eec97b50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edacf290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edcb6990> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyErr_Display(): from sys import version_info module = self.import_extension('foo', [ ("display_error", "METH_VARARGS", r''' PyObject *type, *val, *tb; PyErr_GetExcInfo(&type, &val, &tb); PyErr_Display(type, val, tb); Py_XDECREF(type); Py_XDECREF(val); Py_XDECREF(tb); Py_RETURN_NONE; '''), ]) import io, sys sys.stderr = io.StringIO() try: 1 / 0 except ZeroDivisionError: module.display_error() finally: output = sys.stderr.getvalue() sys.stderr = sys.__stderr__ assert "in test_PyErr_Display\n" in output assert "ZeroDivisionError" in output try: test_PyErr_Display() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestFetch.test_PyErr_Format ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc39150>, 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_PyErr_Format'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_Format'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyErr_Format'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_Format'>} 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_PyErr_Format'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_Format'>} 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_PyErr_Format'>, '__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 0x7ff8edbf3f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Err_Format'>, '__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 0x7ff8edbf31e0> 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 0x7ff8edbf31e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Err_Format'>, '__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_PyErr_Format'>, '__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 0x7ff8edbf36e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Err_Format'>, '__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 0x7ff8edbf3550> 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 0x7ff8edbf3550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Err_Format'>, '__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_PyErr_Format'>, '__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_PyErr_Format'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyErr_Format'> 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_PyErr_Format at 0x7ff8eec97c50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edb39a50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb39a10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyErr_Format(): import warnings module = self.import_extension('foo', [ ("test_warning", "METH_NOARGS", ''' PyErr_WarnFormat(PyExc_UserWarning, 1, "foo %d bar", 42); Py_RETURN_NONE; '''), ("test_err", "METH_NOARGS", ''' return helper(PyExc_ValueError, "foo %d bar %d", 42, 11); ''')], prologue=""" PyObject * helper(PyObject *exception, char * fmt, ...); PyObject * helper(PyObject *exception, char * fmt, ...) { va_list va; va_start(va, fmt); PyErr_FormatV(exception, fmt, va); va_end(va); return NULL; } """ ) with warnings.catch_warnings(record=True) as l: module.test_warning() assert len(l) == 1 assert "foo 42 bar" in str(l[0]) raises (ValueError, module.test_err) try: test_PyErr_Format() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestFetch.test_StopIteration_value _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edb00450>, 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_StopIteration_value'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_StopIteration_value'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_StopIteration_value'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_StopIteration_value'>} 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_StopIteration_value'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_StopIteration_value'>} 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_StopIteration_value'>, '__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 0x7ff8edb4b5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tion_value'>, '__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 0x7ff8edb4b690> 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 0x7ff8edb4b690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tion_value'>, '__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_StopIteration_value'>, '__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 0x7ff8edb4b730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tion_value'>, '__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 0x7ff8edb4b820> 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 0x7ff8edb4b820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...tion_value'>, '__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_StopIteration_value'>, '__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_StopIteration_value'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_StopIteration_value'> 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_StopIteration_value at 0x7ff8eec97cd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edacf990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc7aa90> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_StopIteration_value(): module = self.import_extension('foo', [ ("test", "METH_O", ''' PyObject *o = ((PyStopIterationObject *)args)->value; Py_INCREF(o); return o; '''), ]) res = module.test(StopIteration("foo!")) assert res == "foo!" try: test_StopIteration_value() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestFetch.test_PyErr_BadInternalCall ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc688d0>, 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_PyErr_BadInternalCall'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_BadInternalCall'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_PyErr_BadInternalCall'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_BadInternalCall'>} 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_PyErr_BadInternalCall'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_PyErr_BadInternalCall'>} 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_PyErr_BadInternalCall'>, '__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 0x7ff8edb63960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ternalCall'>, '__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 0x7ff8edb63a50> 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 0x7ff8edb63a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ternalCall'>, '__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_PyErr_BadInternalCall'>, '__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 0x7ff8edb63af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ternalCall'>, '__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 0x7ff8edb63be0> 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 0x7ff8edb63be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ternalCall'>, '__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_PyErr_BadInternalCall'>, '__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_PyErr_BadInternalCall'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_PyErr_BadInternalCall'> 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_PyErr_BadInternalCall at 0x7ff8eec97d50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edd98990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edcb6810> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_PyErr_BadInternalCall(): # NB. it only seemed to fail when run with '-s'... but I think # that it always printed stuff to stderr module = self.import_extension('foo', [ ("oops", "METH_NOARGS", r''' PyErr_BadInternalCall(); return NULL; '''), ]) raises(SystemError, module.oops) try: test_PyErr_BadInternalCall() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestFetch.test_error_thread_race ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd99050>, 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_error_thread_race'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_error_thread_race'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_error_thread_race'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_error_thread_race'>} 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_error_thread_race'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_error_thread_race'>} 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_error_thread_race'>, '__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 0x7ff8edbf3550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hread_race'>, '__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 0x7ff8edbf3d70> 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 0x7ff8edbf3d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hread_race'>, '__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_error_thread_race'>, '__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 0x7ff8edbf36e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hread_race'>, '__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 0x7ff8edca65f0> 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 0x7ff8edca65f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...hread_race'>, '__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_error_thread_race'>, '__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_error_thread_race'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_error_thread_race'> 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_error_thread_race at 0x7ff8eec97dd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edb39a10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edc93750> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_error_thread_race(): # Check race condition: thread 0 returns from cpyext with error set, # after thread 1 has set an error but before it returns. module = self.import_extension('foo', [ ("emit_error", "METH_VARARGS", ''' PyThreadState *save = NULL; PyGILState_STATE gilsave; /* NB. synchronization due to GIL */ static volatile int flag = 0; int id; if (!PyArg_ParseTuple(args, "i", &id)) return NULL; /* Proceed in thread 1 first */ save = PyEval_SaveThread(); if (save == NULL) abort(); while (id == 0 && flag == 0); gilsave = PyGILState_Ensure(); if (gilsave != PyGILState_UNLOCKED) abort(); PyErr_Format(PyExc_ValueError, "%d", id); /* Proceed in thread 0 first */ if (id == 1) flag = 1; PyGILState_Release(gilsave); while (id == 1 && flag == 1); PyEval_RestoreThread(save); if (id == 0) flag = 0; return NULL; ''' ), ]) import threading failures = [] def worker(arg): try: module.emit_error(arg) failures.append(True) except Exception as exc: if str(exc) != str(arg): failures.append(exc) threads = [threading.Thread(target=worker, args=(j,)) for j in (0, 1)] for t in threads: t.start() for t in threads: t.join() assert not failures try: test_error_thread_race() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________________ AppTestFetch.test_format ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eddf2ed0>, 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_format'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_format'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_format'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_format'>} 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_format'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_format'>} 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_format'>, '__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 0x7ff8edb2feb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_format'>, '__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 0x7ff8edb2fcd0> 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 0x7ff8edb2fcd0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_format'>, '__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_format'>, '__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 0x7ff8edb24f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_format'>, '__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 0x7ff8edb248c0> 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 0x7ff8edb248c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_format'>, '__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_format'>, '__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_format'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_format'> 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_format at 0x7ff8eec97e50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edaca090>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edaca750> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_format(): module = self.import_extension('foo', [ ("raises", "METH_NOARGS", ''' PyErr_Format(PyExc_IndexError, "v1 %ld is out of bounds " "for v2 %d with v3 %ld", 4, 0, 4); return NULL; '''), ]) raises(IndexError, module.raises) try: test_format() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestFetch.test_WriteUnraisable _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd99050>, 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_WriteUnraisable'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_WriteUnraisable'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_WriteUnraisable'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_WriteUnraisable'>} 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_WriteUnraisable'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_WriteUnraisable'>} 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_WriteUnraisable'>, '__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 0x7ff8eda45a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Unraisable'>, '__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 0x7ff8eda45af0> 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 0x7ff8eda45af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Unraisable'>, '__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_WriteUnraisable'>, '__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 0x7ff8eda45b90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Unraisable'>, '__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 0x7ff8eda45c80> 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 0x7ff8eda45c80> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...Unraisable'>, '__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_WriteUnraisable'>, '__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_WriteUnraisable'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_WriteUnraisable'> 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_WriteUnraisable at 0x7ff8eec97ed0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edafcd90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edafc1d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_WriteUnraisable(): # Use work-around since cpyext does not set the app-level exc_info # until exiting the c-extenstion module function module = self.import_extension('foo', [ ("unraisable", "METH_O", ''' PyErr_SetString(PyExc_ValueError, "message"); /* args is "location" */ PyErr_WriteUnraisable(args); PyErr_Clear(); Py_RETURN_NONE; '''), ("unraisable_exc", "METH_VARARGS", ''' PyObject *exc, *err_msg, *obj; if (!PyArg_ParseTuple(args, "OOO", &exc, &err_msg, &obj)) { return NULL; } const char *err_msg_utf8; if (err_msg != Py_None) { err_msg_utf8 = PyUnicode_AsUTF8(err_msg); if (err_msg_utf8 == NULL) { return NULL; } } else { err_msg_utf8 = NULL; } PyErr_SetObject((PyObject *)Py_TYPE(exc), exc); _PyErr_WriteUnraisableMsg(err_msg_utf8, obj); Py_RETURN_NONE; '''), ]) import sys import io, sys old = sys.stderr sys.stderr = io.StringIO() module.unraisable('location') output = sys.stderr.getvalue() sys.stderr = old msg = output.strip().replace('\r', '').splitlines() assert msg[0] == "Exception ignored in: 'location'" assert msg[-1] == "ValueError: message" # Taken from lib-python/3/test/audit-tests.py def unraisablehook(hookargs): pass def hook(event, args): if event == "sys.unraisablehook": if args[0] != unraisablehook: raise ValueError("Expected {} == {}".format(args[0], unraisablehook)) print(event, repr(args[1].exc_value), args[1].err_msg) old = sys.stdout sys.stdout = io.StringIO() sys.addaudithook(hook) sys.unraisablehook = unraisablehook module.unraisable_exc(RuntimeError("nonfatal-error"), "sometext", None) output = sys.stdout.getvalue() sys.stdout = old msg = output.strip().replace('\r', '').splitlines() assert msg[0] == "sys.unraisablehook RuntimeError('nonfatal-error') Exception ignored sometext" try: test_WriteUnraisable() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestFetch.test_fetch_normalized ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd99c50>, 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_fetch_normalized'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fetch_normalized'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fetch_normalized'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fetch_normalized'>} 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_fetch_normalized'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fetch_normalized'>} 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_fetch_normalized'>, '__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 0x7ff8eda72500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...normalized'>, '__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 0x7ff8eda725a0> 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 0x7ff8eda725a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...normalized'>, '__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_fetch_normalized'>, '__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 0x7ff8eda72690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...normalized'>, '__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 0x7ff8eda725f0> 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 0x7ff8eda725f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...normalized'>, '__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_fetch_normalized'>, '__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_fetch_normalized'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fetch_normalized'> 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_fetch_normalized at 0x7ff8eec97f50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edaf9b10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edaca750> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_fetch_normalized(): module = self.import_extension('foo', [ ("clevel_error", "METH_O", ''' const char *fname = PyUnicode_AsUTF8(args); char buffer[1024]; sprintf(buffer, "open('%s', 'r')", fname); // printf("calling %s\\n", buffer); PyObject *ret = PyRun_String(buffer, Py_eval_input, pyx_d, pyx_d); if (ret) { Py_DECREF(ret); PyErr_SetString(PyExc_AssertionError, "should raise"); return NULL; } PyObject *type, *value, *tb; PyErr_Fetch(&type, &value, &tb); if (type != PyExc_FileNotFoundError) { // printf("type is %s\\n", ((PyTypeObject*)type)->tp_name); return value; } PyErr_Clear(); // decrefs? Py_RETURN_TRUE; '''), ], prologue=""" static PyObject * pyx_d; """, more_init=""" pyx_d = PyModule_GetDict(mod); """) import os fname = 'this file should not exist' assert not os.path.exists(fname) ret = module.clevel_error(fname) print(ret) assert ret is True try: test_fetch_normalized() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________________ AppTestFetch.test_set_get ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd99050>, 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_set_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_set_get'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_set_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_set_get'>} 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_set_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_set_get'>} 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_set_get'>, '__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 0x7ff8edae5690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_set_get'>, '__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 0x7ff8edb63f00> 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 0x7ff8edb63f00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_set_get'>, '__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_set_get'>, '__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 0x7ff8eda458c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_set_get'>, '__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 0x7ff8eda45af0> 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 0x7ff8eda45af0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_set_get'>, '__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_set_get'>, '__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_set_get'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_set_get'> 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_set_get at 0x7ff8eec98050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edb52310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb52950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_set_get(): # taken from test_capi module = self.import_extension('foo', [ ('set_exception', "METH_O", """ PyObject *exc = PyErr_GetHandledException(); assert(PyExceptionInstance_Check(exc) || exc == NULL); PyErr_SetHandledException(args); return exc; """)]) import sys raised_exception = ValueError("5") new_exc = TypeError("TEST") try: raise raised_exception except ValueError as e: orig_sys_exception = sys.exception() orig_exception = module.set_exception(new_exc) new_sys_exception = sys.exception() new_exception = module.set_exception(orig_exception) reset_sys_exception = sys.exception() assert orig_exception == e assert orig_exception == raised_exception assert orig_sys_exception == orig_exception print(repr(orig_exception), type(reset_sys_exception), repr(reset_sys_exception)) assert reset_sys_exception == orig_exception assert new_exception == new_exc assert new_sys_exception == new_exception else: assert False try: test_set_get() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________ AppTestFetch.test_exc_set_object_broken_subclasscheck _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edb0a850>, 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_exc_set_object_broken_subclassc...': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_exc_set_object_broken_subclasscheck'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_exc_set_object_broken_subclassc...': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_exc_set_object_broken_subclasscheck'>} 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_exc_set_object_broken_subclassc...': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_exc_set_object_broken_subclasscheck'>} 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_exc_set_object_broken_subclasscheck'>, '__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 0x7ff8ed9f4320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...classcheck'>, '__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 0x7ff8ed9f4500> 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 0x7ff8ed9f4500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...classcheck'>, '__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_exc_set_object_broken_subclasscheck'>, '__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 0x7ff8ed9f45f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...classcheck'>, '__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 0x7ff8ed9f4690> 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 0x7ff8ed9f4690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...classcheck'>, '__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_exc_set_object_broken_subclasscheck'>, '__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_exc_set_object_broken_subclasscheck'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_exc_set_object_broken_subclasscheck'> 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_exc_set_object_broken_subclasscheck at 0x7ff8eec980d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestFetch.w_compile_module of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch ...AppTestFetch.w_import_extension of <pypy.module.cpyext.test.test_pyerrors.AppTestFetch object at 0x7ff8edacafd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb6f290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.special_char = None self.udir = '/tmp/pytest/usession-py3.12-215' def test_exc_set_object_broken_subclasscheck(): # taken from test_capi test_set_object: # PyErr_SetObject triggers normalization which calls issubclass(); # if the exc type's metaclass __subclasscheck__ raises, that # exception should propagate out of the C call. module = self.import_extension('foo', [ ('exc_set_object', "METH_VARARGS", """ PyObject *exc, *obj; if (!PyArg_ParseTuple(args, "OO:exc_set_object", &exc, &obj)) return NULL; PyErr_SetObject(exc, obj); return NULL; """), ]) def broken_subclasscheck(cls, sub): 1/0 Meta = type('Meta', (type,), {'__subclasscheck__': broken_subclasscheck}) Broken = Meta('Broken', (Exception,), {}) raises(ZeroDivisionError, module.exc_set_object, Broken, Broken()) try: test_exc_set_object_broken_subclasscheck() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestPyMem.test_pymem_alloc _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edd8e850>, 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_pymem_alloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pymem_alloc'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_pymem_alloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pymem_alloc'>} 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_pymem_alloc'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_pymem_alloc'>} 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_pymem_alloc'>, '__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 0x7ff8edbb9d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ymem_alloc'>, '__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 0x7ff8edbb98c0> 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 0x7ff8edbb98c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ymem_alloc'>, '__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_pymem_alloc'>, '__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 0x7ff8edb24f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ymem_alloc'>, '__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 0x7ff8edb24320> 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 0x7ff8edb24320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ymem_alloc'>, '__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_pymem_alloc'>, '__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_pymem_alloc'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_pymem_alloc'> 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_pymem_alloc at 0x7ff8eecc0550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyMem.w_compile_module of <pypy.module.cpyext.test.test_pymem.AppTestPyMem obj...od AppTestPyMem.w_import_extension of <pypy.module.cpyext.test.test_pymem.AppTestPyMem object at 0x7ff8eda79850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda79550> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_pymem_alloc(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ int *a, *b; a = PyMem_RawCalloc(4, 50); if (a[49] != 0) { PyErr_SetString(PyExc_ValueError, "1"); return NULL; } a[49] = 123456; b = PyMem_RawRealloc(a, 2000); b[499] = 789123; PyMem_RawFree(b); a = PyMem_Calloc(4, 50); if (a[49] != 0) { PyErr_SetString(PyExc_ValueError, "2"); return NULL; } a[49] = 123456; b = PyMem_Realloc(a, 2000); b[499] = 789123; PyMem_Free(b); Py_RETURN_NONE; """), ]) res = module.test() assert res is None try: test_pymem_alloc() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestBufferObject.test_signals _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcad850>, 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_signals'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_signals'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_signals'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_signals'>} 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_signals'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_signals'>} 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_signals'>, '__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 0x7ff8ed9df8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_signals'>, '__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 0x7ff8ed9df9b0> 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 0x7ff8ed9df9b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_signals'>, '__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_signals'>, '__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 0x7ff8ed9dfa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_signals'>, '__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 0x7ff8ed9dfb40> 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 0x7ff8ed9dfb40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_signals'>, '__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_signals'>, '__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_signals'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_signals'> 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_signals at 0x7ff8eecc0850> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestBufferObject.w_compile_module of <pypy.module.cpyext.test.test_pysignals.AppTe...ject.w_import_extension of <pypy.module.cpyext.test.test_pysignals.AppTestBufferObject object at 0x7ff8edb72910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb72810> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_signals(): module = self.import_extension('foo', [ ("test_signals", "METH_NOARGS", """ PyOS_sighandler_t handler = SIG_IGN; PyOS_sighandler_t oldhandler; int result = 0; oldhandler = PyOS_getsig(SIGFPE); handler = PyOS_setsig(SIGFPE, SIG_IGN); if( oldhandler != handler ) result += 1; handler = PyOS_setsig(SIGFPE, oldhandler); if( handler != SIG_IGN ) result += 2; return PyLong_FromLong(result); """), ], prologue = """ #include <signal.h> """) res = module.test_signals() assert res == 0 try: test_signals() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestThreads.test_allow_threads _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edcb22d0>, 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_allow_threads'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_allow_threads'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_allow_threads'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_allow_threads'>} 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_allow_threads'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_allow_threads'>} 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_allow_threads'>, '__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 0x7ff8eda46dc0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_threads'>, '__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 0x7ff8edb50eb0> 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 0x7ff8edb50eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_threads'>, '__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_allow_threads'>, '__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 0x7ff8ed9f4d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_threads'>, '__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 0x7ff8ed9f4eb0> 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 0x7ff8ed9f4eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ow_threads'>, '__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_allow_threads'>, '__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_allow_threads'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_allow_threads'> 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_allow_threads at 0x7ff8eed03f50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8eda475d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda47290> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_allow_threads(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ Py_BEGIN_ALLOW_THREADS { Py_BLOCK_THREADS Py_UNBLOCK_THREADS } Py_END_ALLOW_THREADS Py_RETURN_NONE; """), ]) # Should compile at least module.test() try: test_allow_threads() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestThreads.test_gilstate _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc18ad0>, 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_gilstate'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_gilstate'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_gilstate'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_gilstate'>} 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_gilstate'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_gilstate'>} 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_gilstate'>, '__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 0x7ff8ed9fa820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_gilstate'>, '__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 0x7ff8ed9faaa0> 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 0x7ff8ed9faaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_gilstate'>, '__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_gilstate'>, '__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 0x7ff8ed9fab90> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_gilstate'>, '__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 0x7ff8ed9fac30> 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 0x7ff8ed9fac30> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_gilstate'>, '__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_gilstate'>, '__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_gilstate'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_gilstate'> 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_gilstate at 0x7ff8eed25050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8edb724d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda57ad0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_gilstate(): module = self.import_extension('foo', [ ("double_ensure", "METH_O", ''' PyGILState_STATE state0, state1; int val = PyLong_AsLong(args); PyEval_InitThreads(); state0 = PyGILState_Ensure(); /* hangs here */ if (val != 0) { state1 = PyGILState_Ensure(); PyGILState_Release(state1); } PyGILState_Release(state0); Py_RETURN_NONE; '''), ]) module.double_ensure(0) module.double_ensure(1) try: test_gilstate() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestThreads.test_finalizing ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edb1d250>, 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_finalizing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_finalizing'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_finalizing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_finalizing'>} 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_finalizing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_finalizing'>} 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_finalizing'>, '__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 0x7ff8ed9fa1e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...finalizing'>, '__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 0x7ff8ed9faaf0> 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 0x7ff8ed9faaf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...finalizing'>, '__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_finalizing'>, '__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 0x7ff8ed9fa780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...finalizing'>, '__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 0x7ff8ed9faf50> 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 0x7ff8ed9faf50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...finalizing'>, '__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_finalizing'>, '__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_finalizing'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_finalizing'> 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_finalizing at 0x7ff8eed250d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8edb5a350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb5aa50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_finalizing(): module = self.import_extension('foo', [ ("get", "METH_NOARGS", """ if (_Py_Finalizing) { return PyLong_FromLong(0); } if (_Py_Finalizing != NULL) { return PyLong_FromLong(1); } if (_Py_IsFinalizing()) { return PyLong_FromLong(2); } return PyLong_FromLong(3); """), ]) assert module.get() == 3 try: test_finalizing() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestThreads.test_thread_state_get _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edca0ad0>, 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_thread_state_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_state_get'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_thread_state_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_state_get'>} 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_thread_state_get'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_state_get'>} 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_thread_state_get'>, '__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 0x7ff8edbb9d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._state_get'>, '__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 0x7ff8edbb9370> 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 0x7ff8edbb9370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._state_get'>, '__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_thread_state_get'>, '__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 0x7ff8edb5ee60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._state_get'>, '__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 0x7ff8edb5eaa0> 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 0x7ff8edb5eaa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._state_get'>, '__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_thread_state_get'>, '__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_thread_state_get'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_thread_state_get'> 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_thread_state_get at 0x7ff8eed25150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8ed9c6c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9c6ed0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_thread_state_get(): module = self.import_extension('foo', [ ("get", "METH_NOARGS", """ PyThreadState *tstate = PyThreadState_Get(); if (tstate == NULL) { return PyLong_FromLong(0); } PyInterpreterState *interp = PyThreadState_GetInterpreter(tstate); if (interp != PyInterpreterState_Head()) { return PyLong_FromLong(1); } if (PyInterpreterState_Next(interp) != NULL) { return PyLong_FromLong(2); } if (tstate != _PyThreadState_UncheckedGet()) { return PyLong_FromLong(4); } if (tstate != PyGILState_GetThisThreadState()) { return PyLong_FromLong(8); } int64_t id = PyThreadState_GetID(tstate); return PyLong_FromLong(id + 100); """), ]) assert module.get() > 100 try: test_thread_state_get() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestThreads.test_threadstate_dict _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbe9450>, 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_threadstate_dict'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_threadstate_dict'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_threadstate_dict'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_threadstate_dict'>} 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_threadstate_dict'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_threadstate_dict'>} 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_threadstate_dict'>, '__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 0x7ff8edc915f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...state_dict'>, '__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 0x7ff8edc91410> 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 0x7ff8edc91410> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...state_dict'>, '__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_threadstate_dict'>, '__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 0x7ff8edc91be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...state_dict'>, '__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 0x7ff8edc91e60> 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 0x7ff8edc91e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...state_dict'>, '__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_threadstate_dict'>, '__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_threadstate_dict'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_threadstate_dict'> 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_threadstate_dict at 0x7ff8eed25250> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8ed9f6110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9f62d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_threadstate_dict(): module = self.import_extension('foo', [ ("getdict", "METH_NOARGS", """ PyObject *dict = PyThreadState_GetDict(); Py_INCREF(dict); return dict; """), ]) assert isinstance(module.getdict(), dict) try: test_threadstate_dict() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestThreads.test_savethread ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edb1d150>, 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_savethread'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_savethread'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_savethread'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_savethread'>} 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_savethread'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_savethread'>} 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_savethread'>, '__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 0x7ff8eda02500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...savethread'>, '__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 0x7ff8eda022d0> 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 0x7ff8eda022d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...savethread'>, '__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_savethread'>, '__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 0x7ff8eda02460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...savethread'>, '__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 0x7ff8eda06d20> 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 0x7ff8eda06d20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...savethread'>, '__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_savethread'>, '__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_savethread'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_savethread'> 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_savethread at 0x7ff8eed252d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8eda47810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9f6250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_savethread(): module = self.import_extension('foo', [ ("bounce", "METH_NOARGS", """ PyThreadState * tstate; if (PyEval_ThreadsInitialized() == 0) { PyEval_InitThreads(); } PyGILState_Ensure(); tstate = PyEval_SaveThread(); if (tstate == NULL) { return PyLong_FromLong(0); } PyEval_RestoreThread(tstate); if (PyThreadState_Get() != tstate) { return PyLong_FromLong(2); } return PyLong_FromLong(3); """), ]) res = module.bounce() assert res == 3 try: test_savethread() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestThreads.test_thread_and_gil ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbe9750>, 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_thread_and_gil'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_and_gil'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_thread_and_gil'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_and_gil'>} 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_thread_and_gil'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_and_gil'>} 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_thread_and_gil'>, '__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 0x7ff8eda847d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_and_gil'>, '__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 0x7ff8eda84a50> 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 0x7ff8eda84a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_and_gil'>, '__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_thread_and_gil'>, '__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 0x7ff8eda84b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_and_gil'>, '__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 0x7ff8eda84be0> 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 0x7ff8eda84be0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_and_gil'>, '__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_thread_and_gil'>, '__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_thread_and_gil'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_thread_and_gil'> 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_thread_and_gil at 0x7ff8eed25350> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8edb72990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9f6310> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_thread_and_gil(): module = self.import_extension('foo', [ ("bounce", "METH_NOARGS", """ PyThreadState * tstate; PyObject *dict; PyGILState_STATE gilstate; if (PyEval_ThreadsInitialized() == 0) { PyEval_InitThreads(); } tstate = PyEval_SaveThread(); if (tstate == NULL) { return PyLong_FromLong(0); } if (PyGILState_Check() != 0) return PyLong_FromLong(-1); dict = PyThreadState_GetDict(); if (dict != NULL) { return PyLong_FromLong(1); } gilstate = PyGILState_Ensure(); dict = PyThreadState_GetDict(); if (dict == NULL) { return PyLong_FromLong(2); } if (PyGILState_Check() != 1) return PyLong_FromLong(-2); PyGILState_Release(gilstate); if (PyGILState_Check() != 0) return PyLong_FromLong(-3); PyEval_RestoreThread(tstate); if (PyThreadState_Get() != tstate) { return PyLong_FromLong(3); } if (PyGILState_Check() != 1) return PyLong_FromLong(-4); return PyLong_FromLong(4); """)]) res = module.bounce() assert res == 4 try: test_thread_and_gil() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________ AppTestThreads.test_nested_pygilstate_ensure _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eda2dcd0>, 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_nested_pygilstate_ensure'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nested_pygilstate_ensure'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_nested_pygilstate_ensure'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nested_pygilstate_ensure'>} 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_nested_pygilstate_ensure'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nested_pygilstate_ensure'>} 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_nested_pygilstate_ensure'>, '__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 0x7ff8eda5f730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ate_ensure'>, '__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 0x7ff8eda5f960> 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 0x7ff8eda5f960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ate_ensure'>, '__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_nested_pygilstate_ensure'>, '__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 0x7ff8eda5f0f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ate_ensure'>, '__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 0x7ff8eda5f4b0> 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 0x7ff8eda5f4b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ate_ensure'>, '__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_nested_pygilstate_ensure'>, '__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_nested_pygilstate_ensure'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_nested_pygilstate_ensure'> 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_nested_pygilstate_ensure at 0x7ff8eed253d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8eda16b90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda16590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_nested_pygilstate_ensure(): module = self.import_extension('foo', [ ("bounce", "METH_NOARGS", """ PyGILState_STATE gilstate; PyObject *dict; if (PyEval_ThreadsInitialized() == 0) PyEval_InitThreads(); dict = PyThreadState_GetDict(); gilstate = PyGILState_Ensure(); PyGILState_Release(gilstate); if (PyThreadState_GetDict() != dict) return PyLong_FromLong(-2); return PyLong_FromLong(4); """)]) res = module.bounce() assert res == 4 try: test_nested_pygilstate_ensure() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestThreads.test_threadsinitialized ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbcdf50>, 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_threadsinitialized'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_threadsinitialized'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_threadsinitialized'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_threadsinitialized'>} 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_threadsinitialized'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_threadsinitialized'>} 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_threadsinitialized'>, '__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 0x7ff8edac0500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nitialized'>, '__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 0x7ff8edac05a0> 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 0x7ff8edac05a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nitialized'>, '__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_threadsinitialized'>, '__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 0x7ff8edac0690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nitialized'>, '__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 0x7ff8edac07d0> 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 0x7ff8edac07d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...nitialized'>, '__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_threadsinitialized'>, '__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_threadsinitialized'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_threadsinitialized'> 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_threadsinitialized at 0x7ff8eed25450> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8edcb4f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb72250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_threadsinitialized(): module = self.import_extension('foo', [ ("test", "METH_NOARGS", """ return PyLong_FromLong(PyEval_ThreadsInitialized()); """), ]) res = module.test() assert res in (0, 1) try: test_threadsinitialized() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestThreads.test_thread_interrupt _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eda49050>, 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_thread_interrupt'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_interrupt'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_thread_interrupt'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_interrupt'>} 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_thread_interrupt'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_thread_interrupt'>} 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_thread_interrupt'>, '__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 0x7ff8edaa35a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interrupt'>, '__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 0x7ff8edaa3690> 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 0x7ff8edaa3690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interrupt'>, '__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_thread_interrupt'>, '__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 0x7ff8edaa3730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interrupt'>, '__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 0x7ff8edaa3820> 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 0x7ff8edaa3820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._interrupt'>, '__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_thread_interrupt'>, '__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_thread_interrupt'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_thread_interrupt'> 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_thread_interrupt at 0x7ff8eed254d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8ed9f6f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9f6750> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_thread_interrupt(): if not self.runappdirect: skip("test fails untranslated for obscure reasons") import signal # to initialize the signal infrastructure import _thread as thread, time module = self.import_extension('disruptor', [ ("surprise", "METH_VARARGS", """ long tid; PyObject *exc; if (!PyArg_ParseTuple(args, "lO", &tid, &exc)) return NULL; return PyLong_FromLong(PyThreadState_SetAsyncExc(tid, exc)); """), ("nosurprise", "METH_VARARGS", """ long tid; if (!PyArg_ParseTuple(args, "l", &tid)) return NULL; return PyLong_FromLong(PyThreadState_SetAsyncExc(tid, NULL)); """), ]) # raise in another thread def f(): try: childstarted.append(thread.get_ident()) while 1: print("waiting in child") time.sleep(0.1) except KeyError: childstarted.pop() else: thread.interrupt_main() # to crash the test cancelled_exception = False for i in range(20): print(i) # first wait for the child to start childstarted = [] thread.start_new_thread(f, ()) for i in range(500): if childstarted: break time.sleep(0.1) # then interrupt it from the main thread res = module.surprise(childstarted[0], KeyError) assert res == 1 # try to cancel the interrupt # this is racing! the child could either have been terminated # already or not try: res = module.nosurprise(childstarted[0]) assert res in (0, 1) except IndexError: pass else: if res == 1: cancelled_exception = True # actually send exception res = module.surprise(childstarted[0], KeyError) assert res in (0, 1) # now wait for the exception to arrive in the child thread # which empties childstarted again for i in range(500): if not childstarted: break time.sleep(0.1) assert res == 1 if self.runappdirect: # only after translation assert cancelled_exception else: # best we can do is check that the test ran pass # raise to main with raises(ValueError): res = module.surprise(thread.get_ident(), ValueError) while 1: print("sleeping") time.sleep(0.1) try: test_thread_interrupt() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestThreads.test_frame_tstate_tracing ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbcdf50>, 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_frame_tstate_tracing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frame_tstate_tracing'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_frame_tstate_tracing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frame_tstate_tracing'>} 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_frame_tstate_tracing'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_frame_tstate_tracing'>} 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_frame_tstate_tracing'>, '__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 0x7ff8ed964550> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...te_tracing'>, '__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 0x7ff8ed964690> 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 0x7ff8ed964690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...te_tracing'>, '__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_frame_tstate_tracing'>, '__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 0x7ff8ed964640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...te_tracing'>, '__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 0x7ff8ed964730> 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 0x7ff8ed964730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...te_tracing'>, '__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_frame_tstate_tracing'>, '__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_frame_tstate_tracing'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_frame_tstate_tracing'> 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_frame_tstate_tracing at 0x7ff8eed25550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestThreads.w_compile_module of <pypy.module.cpyext.test.test_pystate.AppTestThrea...TestThreads.w_import_extension of <pypy.module.cpyext.test.test_pystate.AppTestThreads object at 0x7ff8eda28910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb36fd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_frame_tstate_tracing(): import sys, threading module = self.import_extension('foo', [ ("call_in_temporary_c_thread", "METH_O", """ PyObject *res = NULL; test_c_thread_t test_c_thread; long thread; PyEval_InitThreads(); test_c_thread.start_event = PyThread_allocate_lock(); test_c_thread.exit_event = PyThread_allocate_lock(); test_c_thread.callback = NULL; if (!test_c_thread.start_event || !test_c_thread.exit_event) { PyErr_SetString(PyExc_RuntimeError, "could not allocate lock"); goto exit; } Py_INCREF(args); test_c_thread.callback = args; PyThread_acquire_lock(test_c_thread.start_event, 1); PyThread_acquire_lock(test_c_thread.exit_event, 1); thread = PyThread_start_new_thread(temporary_c_thread, &test_c_thread); if (thread == -1) { PyErr_SetString(PyExc_RuntimeError, "unable to start the thread"); PyThread_release_lock(test_c_thread.start_event); PyThread_release_lock(test_c_thread.exit_event); goto exit; } PyThread_acquire_lock(test_c_thread.start_event, 1); PyThread_release_lock(test_c_thread.start_event); Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(test_c_thread.exit_event, 1); PyThread_release_lock(test_c_thread.exit_event); Py_END_ALLOW_THREADS Py_INCREF(Py_None); res = Py_None; exit: Py_CLEAR(test_c_thread.callback); if (test_c_thread.start_event) PyThread_free_lock(test_c_thread.start_event); if (test_c_thread.exit_event) PyThread_free_lock(test_c_thread.exit_event); return res; """), ], prologue = """ #include "pythread.h" typedef struct { PyThread_type_lock start_event; PyThread_type_lock exit_event; PyObject *callback; } test_c_thread_t; static void temporary_c_thread(void *data) { test_c_thread_t *test_c_thread = data; PyGILState_STATE state; PyObject *res; PyThread_release_lock(test_c_thread->start_event); /* Allocate a Python thread state for this thread */ state = PyGILState_Ensure(); res = PyObject_CallFunction(test_c_thread->callback, "", NULL); Py_CLEAR(test_c_thread->callback); if (res == NULL) { PyErr_Print(); } else { Py_DECREF(res); } /* Destroy the Python thread state for this thread */ PyGILState_Release(state); PyThread_release_lock(test_c_thread->exit_event); /*PyThread_exit_thread(); NOP (on linux) and not implememnted */ }; """) def noop_trace(frame, event, arg): # no operation return noop_trace def generator(): while 1: yield "genereator" def callback(): if callback.gen is None: callback.gen = generator() return next(callback.gen) callback.gen = None old_trace = sys.gettrace() sys.settrace(noop_trace) try: # Install a trace function threading.settrace(noop_trace) # Create a generator in a C thread which exits after the call module.call_in_temporary_c_thread(callback) # Call the generator in a different Python thread, check that the # generator didn't keep a reference to the destroyed thread state for test in range(3): # The trace function is still called here callback() finally: sys.settrace(old_trace) try: test_frame_tstate_tracing() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _________________________ AppTestPyStrHex.test_simple __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc18050>, 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_simple'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_simple'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_simple'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_simple'>} 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_simple'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_simple'>} 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_simple'>, '__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 0x7ff8ed97fa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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 0x7ff8ed97faf0> 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 0x7ff8ed97faf0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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_simple'>, '__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 0x7ff8ed97fbe0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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 0x7ff8ed97fd20> 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 0x7ff8ed97fd20> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_simple'>, '__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_simple'>, '__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_simple'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_simple'> 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_simple at 0x7ff8eed3c050> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestPyStrHex.w_compile_module of <pypy.module.cpyext.test.test_pystrhex.AppTestPyS...tPyStrHex.w_import_extension of <pypy.module.cpyext.test.test_pystrhex.AppTestPyStrHex object at 0x7ff8ed9f6c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9f67d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_simple(): module = self.import_extension('strhex', [ ("new", "METH_NOARGS", """ static char a[] = { (char)255, 0, 65 }; PyObject *o1 = _Py_strhex(a, 3); PyObject *o2 = _Py_strhex_bytes(a, 3); return PyTuple_Pack(2, o1, o2); """)], prologue=""" #include <pystrhex.h> """) o1, o2 = module.new() assert type(o1) is str assert type(o2) is bytes assert o1 == u"ff0041" assert o2 == b"ff0041" try: test_simple() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' __________________ AppTestStringToDouble.test_endswith_space ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbcdf50>, 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_endswith_space'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_endswith_space'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_endswith_space'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_endswith_space'>} 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_endswith_space'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_endswith_space'>} 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_endswith_space'>, '__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 0x7ff8eda2e690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...with_space'>, '__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 0x7ff8ed964640> 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 0x7ff8ed964640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...with_space'>, '__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_endswith_space'>, '__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 0x7ff8ed964e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...with_space'>, '__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 0x7ff8ed964eb0> 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 0x7ff8ed964eb0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...with_space'>, '__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_endswith_space'>, '__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_endswith_space'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_endswith_space'> 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_endswith_space at 0x7ff8eef849d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStringToDouble.w_compile_module of <pypy.module.cpyext.test.test_pystrtod.AppT...ble.w_import_extension of <pypy.module.cpyext.test.test_pystrtod.AppTestStringToDouble object at 0x7ff8eda85c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda85250> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_endswith_space(): module = self.import_extension('foo', [ ("test_convert", "METH_O", ''' Py_ssize_t size; const char *utf8 = PyUnicode_AsUTF8AndSize(args, &size); double result = PyOS_string_to_double(utf8, NULL, NULL); if (result == -1.0 && PyErr_Occurred()) { return NULL; } return PyFloat_FromDouble(result); '''), ]) for s in ('.123 ', 'inf ', 'nan ', '1e500 '): try: module.test_convert(s) except ValueError as e: pass else: assert False, 'did not raise' try: test_endswith_space() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________ AppTestSequenceObject.test_sequence_macro_cast ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbe9ad0>, 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_sequence_macro_cast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_sequence_macro_cast'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_sequence_macro_cast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_sequence_macro_cast'>} 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_sequence_macro_cast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_sequence_macro_cast'>} 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_sequence_macro_cast'>, '__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 0x7ff8eda00820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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 0x7ff8ed964370> 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 0x7ff8ed964370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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_sequence_macro_cast'>, '__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 0x7ff8ed964960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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 0x7ff8ed964230> 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 0x7ff8ed964230> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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_sequence_macro_cast'>, '__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_sequence_macro_cast'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_sequence_macro_cast'> 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_sequence_macro_cast at 0x7ff8eef98a50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSequenceObject.w_compile_module of <pypy.module.cpyext.test.test_sequence.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_sequence.AppTestSequenceObject object at 0x7ff8eda0d450>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda0d590> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_sequence_macro_cast(): module = self.import_extension('foo', [ ("test_macro_cast", "METH_NOARGS", """ PyObject *o = PyList_New(0); PyListObject* l; PyList_Append(o, o); l = (PyListObject*)o; PySequence_Fast_GET_ITEM(o, 0); PySequence_Fast_GET_ITEM(l, 0); PySequence_Fast_GET_SIZE(o); PySequence_Fast_GET_SIZE(l); PySequence_ITEM(o, 0); PySequence_ITEM(l, 0); return o; """ ) ]) try: test_sequence_macro_cast() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestSequenceObject.test_fast ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edb7a0d0>, 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_fast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fast'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fast'>} 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_fast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fast'>} 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_fast'>, '__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 0x7ff8edaa5640> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_fast'>, '__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 0x7ff8edaa5870> 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 0x7ff8edaa5870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_fast'>, '__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_fast'>, '__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 0x7ff8edaa58c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_fast'>, '__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 0x7ff8edaa59b0> 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 0x7ff8edaa59b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...'test_fast'>, '__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_fast'>, '__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_fast'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fast'> 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_fast at 0x7ff8eef98ad0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSequenceObject.w_compile_module of <pypy.module.cpyext.test.test_sequence.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_sequence.AppTestSequenceObject object at 0x7ff8eda0d550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb36950> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fast(): module = self.import_extension('foo', [ ("test_fast_sequence", "METH_VARARGS", """ int size, i; PyTypeObject * common_type; PyObject *foo, **objects; PyObject * seq = PyTuple_GetItem(args, 0); if (seq == NULL) Py_RETURN_NONE; foo = PySequence_Fast(seq, "some string"); objects = PySequence_Fast_ITEMS(foo); if (objects == NULL) return NULL; size = PySequence_Fast_GET_SIZE(foo); for (i = 0; i < size; ++i) { if (objects[i] != PySequence_Fast_GET_ITEM(foo, i)) return PyBool_FromLong(0); } common_type = size > 0 ? Py_TYPE(objects[0]) : NULL; for (i = 1; i < size; ++i) { if (Py_TYPE(objects[i]) != common_type) { common_type = NULL; break; } } Py_DECREF(foo); if (common_type == NULL) return PyBool_FromLong(0); Py_DECREF(common_type); return PyBool_FromLong(1); """)]) s = [1, 2, 3, 4] assert module.test_fast_sequence(s[0:-1]) assert module.test_fast_sequence(s[::-1]) s = (1, 2, 3, 4) assert module.test_fast_sequence(s[0:-1]) assert module.test_fast_sequence(s[::-1]) s = (1, 2) # specialized tuple assert module.test_fast_sequence(s[0:-1]) assert module.test_fast_sequence(s[::-1]) s = "1234" assert module.test_fast_sequence(s[0:-1]) assert module.test_fast_sequence(s[::-1]) try: test_fast() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ___________________ AppTestSequenceObject.test_fast_keyerror ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edbe9ad0>, 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_fast_keyerror'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fast_keyerror'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_fast_keyerror'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fast_keyerror'>} 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_fast_keyerror'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_fast_keyerror'>} 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_fast_keyerror'>, '__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 0x7ff8ed9a95f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_keyerror'>, '__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 0x7ff8ed9a9690> 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 0x7ff8ed9a9690> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_keyerror'>, '__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_fast_keyerror'>, '__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 0x7ff8ed9a9780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_keyerror'>, '__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 0x7ff8ed9a96e0> 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 0x7ff8ed9a96e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_keyerror'>, '__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_fast_keyerror'>, '__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_fast_keyerror'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_fast_keyerror'> 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_fast_keyerror at 0x7ff8eef98b50> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSequenceObject.w_compile_module of <pypy.module.cpyext.test.test_sequence.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_sequence.AppTestSequenceObject object at 0x7ff8eda85b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9f67d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_fast_keyerror(): module = self.import_extension('foo', [ ("test_fast_sequence", "METH_VARARGS", """ PyObject *foo; PyObject * seq = PyTuple_GetItem(args, 0); if (seq == NULL) Py_RETURN_NONE; foo = PySequence_Fast(seq, "Could not convert object to sequence"); if (foo != NULL) { return foo; } if (PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_Clear(); return PyBool_FromLong(1); } return NULL; """)]) class Map(object): def __len__(self): return 1 def __getitem__(self, index): raise KeyError() assert module.test_fast_sequence(Map()) is True try: test_fast_keyerror() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestSequenceObject.test_getitem_c _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eda2d0d0>, 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_getitem_c'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_c'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_getitem_c'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_c'>} 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_getitem_c'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_getitem_c'>} 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_getitem_c'>, '__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 0x7ff8edaa5fa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getitem_c'>, '__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 0x7ff8edaa5190> 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 0x7ff8edaa5190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getitem_c'>, '__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_getitem_c'>, '__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 0x7ff8edaa5f50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getitem_c'>, '__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 0x7ff8ed9a9e60> 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 0x7ff8ed9a9e60> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._getitem_c'>, '__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_getitem_c'>, '__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_getitem_c'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_getitem_c'> 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_getitem_c at 0x7ff8eef98bd0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSequenceObject.w_compile_module of <pypy.module.cpyext.test.test_sequence.AppT...ect.w_import_extension of <pypy.module.cpyext.test.test_sequence.AppTestSequenceObject object at 0x7ff8ed9c6b10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9c6f10> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_getitem_c(): module = self.import_extension('foo', [ ("dict_assignment", "METH_VARARGS", """ PyObject *cls = PyTuple_GetItem(args, 0); PyObject *func = PyTuple_GetItem(args, 1); if (cls == NULL) return NULL; if (func == NULL) return NULL; /* Assign the func to the cls.__dict__ */ if (PyObject_SetAttrString(cls, "__getitem__", func) != 0){ return NULL; } Py_RETURN_NONE; """), ("test_get_item", "METH_VARARGS", """ PyObject *obj, *result=NULL; int i; if (PyArg_ParseTuple(args, "Oi:test_get_item", &obj, &i)) { result = PySequence_GetItem(obj, i); }; return result; """), ]) class A(object): pass def getitem(*args): return 42 module.dict_assignment(A, getitem) a = A() assert a[12] == 42 assert module.test_get_item(a, 0) == 42 assert module.test_get_item(b'a', 0) == ord('a') e = raises(IndexError, module.test_get_item, b'a', -2) assert "bytes index out of range" in str(e.value) raises(IndexError, module.test_get_item, b'a', 1) try: test_getitem_c() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _____________________ AppTestSetObject.test_set_macro_cast _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edc18050>, 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_set_macro_cast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_set_macro_cast'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_set_macro_cast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_set_macro_cast'>} 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_set_macro_cast'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_set_macro_cast'>} 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_set_macro_cast'>, '__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 0x7ff8ed9957d0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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 0x7ff8ed995870> 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 0x7ff8ed995870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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_set_macro_cast'>, '__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 0x7ff8ed995960> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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 0x7ff8ed995aa0> 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 0x7ff8ed995aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...macro_cast'>, '__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_set_macro_cast'>, '__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_set_macro_cast'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_set_macro_cast'> 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_set_macro_cast at 0x7ff8eefa4150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSetObject.w_compile_module of <pypy.module.cpyext.test.test_setobject.AppTestS...tObject.w_import_extension of <pypy.module.cpyext.test.test_setobject.AppTestSetObject object at 0x7ff8ed956890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed956810> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_set_macro_cast(): module = self.import_extension('foo', [ ("test_macro_cast", "METH_NOARGS", """ PyObject* o = PySet_New(NULL); // no PySetObject char* dumb_pointer = (char*) o; PySet_GET_SIZE(o); PySet_GET_SIZE(dumb_pointer); return o; """) ]) try: test_set_macro_cast() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestSliceMembers.test_members _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edaefad0>, 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_members'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_members'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_members'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_members'>} 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_members'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_members'>} 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_members'>, '__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 0x7ff8eda8fa50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_members'>, '__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 0x7ff8eda8f8c0> 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 0x7ff8eda8f8c0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_members'>, '__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_members'>, '__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 0x7ff8eda8f500> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_members'>, '__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 0x7ff8ed97f320> 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 0x7ff8ed97f320> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...st_members'>, '__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_members'>, '__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_members'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_members'> 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_members at 0x7ff8eefac4d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSliceMembers.w_compile_module of <pypy.module.cpyext.test.test_sliceobject.App...rs.w_import_extension of <pypy.module.cpyext.test.test_sliceobject.AppTestSliceMembers object at 0x7ff8edb36790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8edb36050> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_members(): module = self.import_extension('foo', [ ("clone", "METH_O", """ PySliceObject *slice = (PySliceObject *)args; if (Py_TYPE(slice) != &PySlice_Type) { PyErr_SetNone(PyExc_ValueError); return NULL; } return PySlice_New(slice->start, slice->stop, slice->step); """), ]) s = slice(10, 20, 30) assert module.clone(s) == s try: test_members() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ________________________ AppTestSliceMembers.test_nulls ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ed9ec450>, 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_nulls'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nulls'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_nulls'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nulls'>} 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_nulls'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_nulls'>} 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_nulls'>, '__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 0x7ff8ed8d1780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_nulls'>, '__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 0x7ff8ed8d1870> 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 0x7ff8ed8d1870> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_nulls'>, '__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_nulls'>, '__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 0x7ff8ed8d1910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_nulls'>, '__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 0x7ff8ed8d1a00> 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 0x7ff8ed8d1a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...test_nulls'>, '__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_nulls'>, '__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_nulls'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_nulls'> 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_nulls at 0x7ff8eefac550> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSliceMembers.w_compile_module of <pypy.module.cpyext.test.test_sliceobject.App...rs.w_import_extension of <pypy.module.cpyext.test.test_sliceobject.AppTestSliceMembers object at 0x7ff8edb36cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9a23d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_nulls(): module = self.import_extension('foo', [ ("nullslice", "METH_NOARGS", """ return PySlice_New(NULL, NULL, NULL); """), ]) assert module.nullslice() == slice(None, None, None) try: test_nulls() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestSliceMembers.test_ellipsis _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ed9d31d0>, 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_ellipsis'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_ellipsis'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_ellipsis'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_ellipsis'>} 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_ellipsis'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_ellipsis'>} 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_ellipsis'>, '__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 0x7ff8edaa5460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_ellipsis'>, '__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 0x7ff8ed9a9460> 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 0x7ff8ed9a9460> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_ellipsis'>, '__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_ellipsis'>, '__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 0x7ff8eda3ef50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_ellipsis'>, '__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 0x7ff8eda3e5a0> 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 0x7ff8eda3e5a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...t_ellipsis'>, '__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_ellipsis'>, '__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_ellipsis'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_ellipsis'> 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_ellipsis at 0x7ff8eefac5d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSliceMembers.w_compile_module of <pypy.module.cpyext.test.test_sliceobject.App...rs.w_import_extension of <pypy.module.cpyext.test.test_sliceobject.AppTestSliceMembers object at 0x7ff8ed956790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed956f50> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_ellipsis(): module = self.import_extension('foo', [ ("get_ellipsis", "METH_NOARGS", """ PyObject *ret = Py_Ellipsis; Py_INCREF(ret); return ret; """), ]) assert module.get_ellipsis() is Ellipsis try: test_ellipsis() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ______________________ AppTestSliceMembers.test_typecheck ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ed9ecdd0>, 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_typecheck'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typecheck'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_typecheck'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typecheck'>} 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_typecheck'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_typecheck'>} 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_typecheck'>, '__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 0x7ff8ed8e1730> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typecheck'>, '__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 0x7ff8ed8e19b0> 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 0x7ff8ed8e19b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typecheck'>, '__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_typecheck'>, '__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 0x7ff8ed8e1aa0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typecheck'>, '__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 0x7ff8ed8e1b40> 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 0x7ff8ed8e1b40> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._typecheck'>, '__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_typecheck'>, '__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_typecheck'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_typecheck'> 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_typecheck at 0x7ff8eefac650> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSliceMembers.w_compile_module of <pypy.module.cpyext.test.test_sliceobject.App...rs.w_import_extension of <pypy.module.cpyext.test.test_sliceobject.AppTestSliceMembers object at 0x7ff8eda85310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8eda85cd0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_typecheck(): module = self.import_extension('foo', [ ("check", "METH_O", """ PySliceObject *slice = (PySliceObject *)args; return PyLong_FromLong(PySlice_Check(slice)); """), ]) s = slice(10, 20, 30) assert module.check(s) try: test_typecheck() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestSliceMembers.test_Unpack ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ed9d3f50>, 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_Unpack'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Unpack'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_Unpack'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Unpack'>} 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_Unpack'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_Unpack'>} 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_Unpack'>, '__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 0x7ff8ed8d1a00> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Unpack'>, '__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 0x7ff8ed8d1780> 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 0x7ff8ed8d1780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Unpack'>, '__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_Unpack'>, '__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 0x7ff8ed8d14b0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Unpack'>, '__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 0x7ff8ed8d1910> 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 0x7ff8ed8d1910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...est_Unpack'>, '__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_Unpack'>, '__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_Unpack'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_Unpack'> 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_Unpack at 0x7ff8eefac6d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSliceMembers.w_compile_module of <pypy.module.cpyext.test.test_sliceobject.App...rs.w_import_extension of <pypy.module.cpyext.test.test_sliceobject.AppTestSliceMembers object at 0x7ff8eda0d410>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9446d0> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_Unpack(): from sys import maxsize as M module = self.import_extension('foo', [ ("check", "METH_O", """ Py_ssize_t start, stop, step; if (PySlice_Unpack(args, &start, &stop, &step) != 0) return NULL; return Py_BuildValue("nnn", start, stop, step); """), ]) assert module.check(slice(10, 20, 1)) == (10, 20, 1) assert module.check(slice(None, 20, 1)) == (0, 20, 1) assert module.check(slice(10, None, 3)) == (10, M, 3) assert module.check(slice(10, 20, None)) == (10, 20, 1) assert module.check(slice(20, 5, 1)) == (20, 5, 1) assert module.check(slice(None, None, None)) == (0, M, 1) assert module.check(slice(20, 10, -1)) == (20, 10, -1) assert module.check(slice(None, 20, -1)) == (M, 20, -1) assert module.check(slice(10, None, -1)) == (10, -M-1, -1) assert module.check(slice(M*2, M*3, 1)) == (M, M, 1) assert module.check(slice(M*2, -123, 1)) == (M, -123, 1) assert module.check(slice(-M*2, -M*3, 1)) == (-M-1, -M-1, 1) assert module.check(slice(-M*2, 123, -2)) == (-M-1, 123, -2) with raises(ValueError): module.check(slice(2, 3, 0)) assert module.check(slice(2, 3, -M-1)) == (2, 3, -M) assert module.check(slice(2, 3, -M-10)) == (2, 3, -M) assert module.check(slice(2, 3, M+10)) == (2, 3, M) try: test_Unpack() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' ____________________ AppTestSliceMembers.test_AdjustIndices ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8eda812d0>, 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_AdjustIndices'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AdjustIndices'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_AdjustIndices'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AdjustIndices'>} 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_AdjustIndices'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_AdjustIndices'>} 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_AdjustIndices'>, '__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 0x7ff8eda05370> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ustIndices'>, '__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 0x7ff8eda05d70> 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 0x7ff8eda05d70> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ustIndices'>, '__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_AdjustIndices'>, '__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 0x7ff8eda05910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ustIndices'>, '__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 0x7ff8ed9a7190> 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 0x7ff8ed9a7190> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ustIndices'>, '__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_AdjustIndices'>, '__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_AdjustIndices'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_AdjustIndices'> 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_AdjustIndices at 0x7ff8eefac750> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSliceMembers.w_compile_module of <pypy.module.cpyext.test.test_sliceobject.App...rs.w_import_extension of <pypy.module.cpyext.test.test_sliceobject.AppTestSliceMembers object at 0x7ff8ed9bc310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9bc450> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_AdjustIndices(): module = self.import_extension('foo', [ ("check", "METH_NOARGS", """ Py_ssize_t start = -35, stop = 99999, step = 10, result; result = PySlice_AdjustIndices(100, &start, &stop, step); return Py_BuildValue("nnnn", result, start, stop, step); """), ]) assert module.check() == (4, 65, 100, 10) try: test_AdjustIndices() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestStructSeq.test_StructSeq ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8edaf80d0>, 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_StructSeq'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_StructSeq'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_StructSeq'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_StructSeq'>} 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_StructSeq'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_StructSeq'>} 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_StructSeq'>, '__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 0x7ff8ed847780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._StructSeq'>, '__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 0x7ff8ed847820> 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 0x7ff8ed847820> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._StructSeq'>, '__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_StructSeq'>, '__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 0x7ff8ed847910> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._StructSeq'>, '__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 0x7ff8ed847a50> 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 0x7ff8ed847a50> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._StructSeq'>, '__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_StructSeq'>, '__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_StructSeq'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_StructSeq'> 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_StructSeq at 0x7ff8eefac9d0> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestStructSeq.w_compile_module of <pypy.module.cpyext.test.test_structseq.AppTestS...ructSeq.w_import_extension of <pypy.module.cpyext.test.test_structseq.AppTestStructSeq object at 0x7ff8ed9568d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed956850> 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 ModuleNotFoundError: No module named 'imp' 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') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).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 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_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-x86-64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.load_module(mod, name) type(self).load_module = w_load_module self.runappdirect = True self.udir = '/tmp/pytest/usession-py3.12-215' def test_StructSeq(): module = self.import_extension('foo', prologue=""" #include <structseq.h> static PyTypeObject* PyDatatype; static PyStructSequence_Field Data_fields[] = { {"value", "value_doc"}, {"value2", "value_doc"}, {"text", "text_doc"}, {"other", "other_doc"}, {NULL} /* Sentinel */ }; static PyStructSequence_Desc Data_desc = { "cpyext_test.data", /*name*/ "data_doc", /*doc*/ Data_fields, /*fields*/ 3, /*n_in_sequence*/ }; """, more_init = """ """, functions=[ ("new_structdata", "METH_NOARGS", """ PyObject *seq; PyDatatype = PyStructSequence_NewType(&Data_desc); seq = PyStructSequence_New(PyDatatype); if (!seq) return NULL; PyStructSequence_SET_ITEM(seq, 0, PyLong_FromLong(42)); PyStructSequence_SET_ITEM(seq, 1, PyLong_FromLong(43)); PyStructSequence_SetItem(seq, 2, PyUnicode_FromString("hello")); PyStructSequence_SetItem(seq, 3, PyUnicode_FromString("other")); Py_DECREF(PyDatatype); return seq; """), ("getitem", "METH_VARARGS", """ PyObject *obj, *result=NULL; int i; if (PyArg_ParseTuple(args, "Oi:test_get_item", &obj, &i)) { result = PyStructSequence_GetItem(obj, i); Py_INCREF(result); }; return result; """), ]) s = module.new_structdata() assert tuple(s) == (42, 43, 'hello') assert s.value == 42 assert s.text == 'hello' assert s.other == 'other' assert 'hello' in s assert 'other' not in s assert module.getitem(s, 1) == 43 del s try: test_StructSeq() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-215/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- ModuleNotFoundError: No module named 'imp' _______________________ AppTestSysModule.test_sysmodule ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: ModuleNotFoundError: No module named 'imp' > func = <function <lambda> at 0x7ff8ed9ecd50>, 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_sysmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_sysmodule'>} 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 0x7ff8f45b2f50> hook = <_HookCaller 'pytest_runtest_call'>, methods = [] kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_sysmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_sysmodule'>} 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_sysmodule'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_sysmodule'>} 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_sysmodule'>, '__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 0x7ff8ed8605a0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._sysmodule'>, '__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 0x7ff8ed8605f0> 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 0x7ff8ed8605f0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._sysmodule'>, '__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_sysmodule'>, '__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 0x7ff8ed8606e0> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._sysmodule'>, '__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 0x7ff8ed860780> 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 0x7ff8ed860780> func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i..._sysmodule'>, '__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_sysmodule'>, '__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_sysmodule'> def pytest_runtest_call(item): try: > item.runtest() ../_pytest/runner.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <AppTestMethod 'test_sysmodule'> 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_sysmodule at 0x7ff8eec0e150> usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...] definitions = {'compile_module': <bound method AppTestSysModule.w_compile_module of <pypy.module.cpyext.test.test_sysmodule.AppTestS...sModule.w_import_extension of <pypy.module.cpyext.test.test_sysmodule.AppTestSysModule object at 0x7ff8ed9b2f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-215' code = <py._code.code.Code object at 0x7ff8ed9b2b50> 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 i Output exceeded 6164480 bytes, remaining output has been truncated program finished with exit code 1 elapsedTime=609.034872