python testrunner/app_level_tests.py in dir /build_dir/pypy-c-jit-linux-aarch64/build (timeout 4000 secs) watching logfiles {'pytestLog': 'pytest-A.log'} argv: ['python', 'testrunner/app_level_tests.py'] environment: AUDITWHEEL_ARCH=aarch64 AUDITWHEEL_PLAT=manylinux2014_aarch64 AUDITWHEEL_POLICY=manylinux2014 DEVTOOLSET_ROOTPATH=/opt/rh/devtoolset-10/root HOME=/home/buildslave HOSTNAME=530e0d063b5c 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-aarch64/build PYPY_GC_NURSERY=16M PYPY_LOCALBASE=/usr/local PYPY_MAKE_PORTABLE=1 SHELL=/bin/bash SHLVL=2 SSL_CERT_FILE=/opt/_internal/certs.pem TERM=xterm TMPDIR=/tmp/pytest USER=buildslave _=/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 ++ 09:03: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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 15 items interpreter/astcompiler/test/test_compiler.py ..s............ ===================== 14 passed, 1 skipped in 4.56 seconds ===================== ++ 09:03:36 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.52 seconds ========================= ++ 09:03:39 starting interpreter/test [3 started in total] __ interpreter/test [3 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 228 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 .......................s.................................. 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 ............... interpreter/test/test_pyframe.py ..... interpreter/test/test_special.py ... interpreter/test/test_syntax.py ..................................... interpreter/test/test_typedef.py ........... interpreter/test/test_zzpickle_and_slow.py .............................. ==================== 219 passed, 9 skipped in 11.25 seconds ==================== ++ 09:03:53 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:03:55 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 1524 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 sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 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_typeobject.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.....sssssssssssss objspace/std/test/test_unicodeobject.py .... objspace/std/test/test_userobject.py . ================== 1000 passed, 524 skipped in 58.66 seconds =================== ++ 09:05:01 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 10.72 seconds ========================== ++ 09:05:15 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 8.42 seconds ===================== ++ 09:05:25 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 3 items module/_abc/test/test_abc.py ... =========================== 3 passed in 0.33 seconds =========================== ++ 09:05:28 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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: Traceback (most recent call last): File "/tmp/p...) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: required field 'type_params' missing from FunctionDef > func = <function <lambda> at 0xfffd12ca8f50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffd15bf8f50> 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 0xfffd12c52a00> 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 0xfffd12c52050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffd12c52050> 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 0xfffd12c52f50> 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 0xfffd12c52dc0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffd12c52dc0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_functiondef at 0xfffd12f49450> 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 0xfffd12c52460>>} 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 0xfffd12c52460>> code = <py._code.code.Code object at 0xfffd12c65910> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-191/src.py", line 101, in <module> E test_functiondef() E File "/tmp/pytest/usession-py3.12-191/src.py", line 94, in test_functiondef E compiled = compile(exprAst, "<foo>", "single") E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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-aarch64/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-191/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-191/src.py", line 101, in <module> test_functiondef() File "/tmp/pytest/usession-py3.12-191/src.py", line 94, in test_functiondef compiled = compile(exprAst, "<foo>", "single") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: Traceback (most recent call last): File "/tmp/p...ession-py3.12-191/src.py", line 53, in raises raise AssertionError("DID NOT RAISE") AssertionError: DID NOT RAISE > func = <function <lambda> at 0xfffd12be6e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffd15bf8f50> 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 0xfffd12bb4af0> 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 0xfffd12bb4c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffd12bb4c30> 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 0xfffd12bb4190> 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 0xfffd12bb4eb0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffd12bb4eb0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fstring_self_documenting_feature_version at 0xfffd12f49f50> 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 0xfffd12bb4640>>} 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 0xfffd12bb4640>> code = <py._code.code.Code object at 0xfffd12bcf210> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-191/src.py", line 86, in <module> E test_fstring_self_documenting_feature_version() E File "/tmp/pytest/usession-py3.12-191/src.py", line 83, in test_fstring_self_documenting_feature_version E raises(SyntaxError, self.get_ast, "f'{x=}'", feature_version=7) E File "/tmp/pytest/usession-py3.12-191/src.py", line 53, in raises E raise AssertionError("DID NOT RAISE") 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-aarch64/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-191/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-191/src.py", line 86, in <module> test_fstring_self_documenting_feature_version() File "/tmp/pytest/usession-py3.12-191/src.py", line 83, in test_fstring_self_documenting_feature_version raises(SyntaxError, self.get_ast, "f'{x=}'", feature_version=7) File "/tmp/pytest/usession-py3.12-191/src.py", line 53, in raises raise AssertionError("DID NOT RAISE") 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 3.13 seconds ====================== ++ 09:05:33 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 6.06 seconds ==================== ++ 09:05:42 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 89 items module/_codecs/test/test_codecs.py ....................sss.................................................................. ===================== 86 passed, 3 skipped in 4.36 seconds ===================== ++ 09:05:49 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:05:50 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 4.31 seconds ===================== ++ 09:05:57 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.01 seconds ========================= ++ 09:05:59 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 1.25 seconds =========================== ++ 09:06:02 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 1 items module/_demo/test/test_sieve.py s ========================== 1 skipped in 0.26 seconds =========================== ++ 09:06:05 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.01 seconds ========================= ++ 09:06:07 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:06:08 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 7.84 seconds ===================== ++ 09:06:18 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 1 items module/_jitlog/test/test__jitlog.py . =========================== 1 passed in 0.28 seconds =========================== ++ 09:06:21 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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.29 seconds ===================== ++ 09:06:23 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 6 items module/_lsprof/test/test_cprofile.py ...... =========================== 6 passed in 1.45 seconds =========================== ++ 09:06:27 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 8 items module/_md5/test/test_md5.py ........ =========================== 8 passed in 0.52 seconds =========================== ++ 09:06:29 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:06:31 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 3 items module/_multibytecodec/test/test_multibtye_codecs.py ... =========================== 3 passed in 0.40 seconds =========================== ++ 09:06:34 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 1.01 seconds ====================== ++ 09:06:37 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:06:39 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:06:40 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:06:42 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.47 seconds ========================= ++ 09:06:45 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 29 items / 1 skipped module/_pypyjson/test/test__pypyjson.py ............................. ===================== 29 passed, 1 skipped in 1.78 seconds ===================== ++ 09:06: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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 12 items module/_random/test/test_random.py ............ ========================== 12 passed in 0.85 seconds =========================== ++ 09:06:52 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 3.64 seconds ===================== ++ 09:06:58 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 3.88 seconds ===================== ++ 09:07:05 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 2.27 seconds ========================= ++ 09:07:09 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 4.39 seconds ===================== ++ 09:07:16 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 5 items module/_vmprof/test/test__vmprof.py ..... =========================== 5 passed in 0.73 seconds =========================== ++ 09:07:19 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:07:20 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:07:22 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items / 1 skipped ========================== 1 skipped in 0.02 seconds =========================== ++ 09:07:24 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 60 items module/array/test/test_array.py ............................................................ ========================== 60 passed in 2.65 seconds =========================== ++ 09:07:28 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 0 items ========================= no tests ran in 0.00 seconds ========================= ++ 09:07:30 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 18 items module/binascii/test/test_binascii.py .................. ========================== 18 passed in 1.01 seconds =========================== ++ 09:07:33 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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 2.26 seconds ========================== ++ 09:07:38 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/build, inifile: pytest.ini plugins: hypothesis-4.42.0 collected 16 items module/cmath/test/test_cmath.py ................ ========================== 16 passed in 0.81 seconds =========================== ++ 09:07:40 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-aarch64/build/pypy/.hypothesis/examples') pytest-2.9.2 from /build_dir/pypy-c-jit-linux-aarch64/build/pytest.pyc rootdir: /build_dir/pypy-c-jit-linux-aarch64/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: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80ece230> 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 0xfffe810755f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810755f0> 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 0xfffe80ecc730> 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 0xfffe80eccaa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80eccaa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_basic at 0xfffe81998250> 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 0xfffe81003a10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe86fa9850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_basic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_basic E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_basic() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_basic module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestArrayModule.test_iter _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe81009f50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e015a0> 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 0xfffe80e01640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e01640> 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 0xfffe80e01730> 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 0xfffe80e01870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e01870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_iter at 0xfffe819982d0> 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 0xfffe8117f290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8117f1d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> E test_iter() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iter E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> test_iter() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iter module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestArrayModule.test_index _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a7d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e0d7d0> 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 0xfffe80e0db40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e0db40> 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 0xfffe80e0d9b0> 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 0xfffe80e0d730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e0d730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_index at 0xfffe81998350> 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 0xfffe8117fa10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80de8290> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_index() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_index E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_index() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_index module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestArrayModule.test_slice_get _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe811189d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe814dd500> 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 0xfffe80e356e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e356e0> 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 0xfffe80e35050> 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 0xfffe80e35870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e35870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_slice_get at 0xfffe819983d0> 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 0xfffe80f1de50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f1dbd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> E test_slice_get() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_slice_get E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> test_slice_get() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_slice_get module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestArrayModule.test_slice_object _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a5d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe810b96e0> 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 0xfffe810b9780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810b9780> 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 0xfffe810b9870> 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 0xfffe810b97d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810b97d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_slice_object at 0xfffe81998450> 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 0xfffe81117790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80de8f10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_slice_object() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_slice_object E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_slice_object() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_slice_object module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestArrayModule.test_buffer ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe811182d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8114d6e0> 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 0xfffe8114d690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8114d690> 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 0xfffe8114d410> 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 0xfffe80d969b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d969b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_buffer at 0xfffe819984d0> 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 0xfffe8117f050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8117f850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_buffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_buffer E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_buffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_buffer module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestArrayModule.test_releasebuffer _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e55870> 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 0xfffe80e55960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e55960> 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 0xfffe80e55a00> 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 0xfffe80e55af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e55af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_releasebuffer at 0xfffe81998550> 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 0xfffe81003550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe81003650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> E test_releasebuffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_releasebuffer E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> test_releasebuffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_releasebuffer module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestArrayModule.test_Py_buffer _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80de2650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8114a500> 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 0xfffe8114a460> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8114a460> 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 0xfffe8114a5a0> 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 0xfffe8114a640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8114a640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Py_buffer at 0xfffe819985d0> 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 0xfffe8117f610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe810035d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_Py_buffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_Py_buffer E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_Py_buffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_Py_buffer module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestArrayModule.test_0d_view ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f3d2d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80d6ba50> 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 0xfffe80d6bb40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d6bb40> 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 0xfffe80d6bbe0> 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 0xfffe80d6bcd0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d6bcd0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_0d_view at 0xfffe81998650> 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 0xfffe80de8510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe81003fd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> E test_0d_view() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_0d_view E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> test_0d_view() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_0d_view module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestArrayModule.test_binop_mul_impl ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80de2650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe810b5410> 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 0xfffe810b5500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810b5500> 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 0xfffe810b55a0> 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 0xfffe810b5690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810b5690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_binop_mul_impl at 0xfffe819986d0> 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 0xfffe80ed0f90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ed01d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> E test_binop_mul_impl() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_binop_mul_impl E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> test_binop_mul_impl() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_binop_mul_impl module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestArrayModule.test_string_buf ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a7d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80d105f0> 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 0xfffe80d107d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d107d0> 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 0xfffe80d108c0> 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 0xfffe80d10960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d10960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_string_buf at 0xfffe819987d0> 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 0xfffe80d9d210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80d9d690> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_string_buf() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_string_buf E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_string_buf() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_string_buf module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestArrayModule.test_subclass _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f92cd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80d2b500> 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 0xfffe80d2b460> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d2b460> 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 0xfffe80d2b5a0> 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 0xfffe80d2b640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d2b640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_subclass at 0xfffe81998850> 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 0xfffe8109c850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109c310> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_subclass() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_subclass E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_subclass() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_subclass module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestArrayModule.test_unicode_readbuffer __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f42850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe810b5230> 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 0xfffe80d6bd20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d6bd20> 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 0xfffe810b6870> 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 0xfffe810b62d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810b62d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_unicode_readbuffer at 0xfffe819988d0> 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 0xfffe8109c110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109c050> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> E test_unicode_readbuffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_unicode_readbuffer E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> test_unicode_readbuffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_unicode_readbuffer module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestArrayModule.test_readinto _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f3dc50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80dce4b0> 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 0xfffe80dce5a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80dce5a0> 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 0xfffe80dce640> 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 0xfffe80dce730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80dce730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_readinto at 0xfffe81998950> 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 0xfffe8109c3d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109ce50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_readinto() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_readinto E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_readinto() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_readinto module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestArrayModule.test_iowrite ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f42850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e821e0> 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 0xfffe80d933c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d933c0> 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 0xfffe80d93640> 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 0xfffe80d93cd0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d93cd0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_iowrite at 0xfffe819989d0> 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 0xfffe8109cd50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109c7d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_iowrite() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iowrite E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_iowrite() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iowrite module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________ AppTestArrayModule.test_getitem_via_PySequence_GetItem ____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80df1cd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80cd5870> 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 0xfffe80cd5960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cd5960> 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 0xfffe80cd5a00> 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 0xfffe80cd5af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cd5af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getitem_via_PySequence_GetItem at 0xfffe81998a50> 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 0xfffe80dcae90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109c190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_getitem_via_PySequence_GetItem() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getitem_via_PySequence_GetItem E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_getitem_via_PySequence_GetItem() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getitem_via_PySequence_GetItem module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestArrayModule.test_subclass_with_attribute ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80df1450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80cd5280> 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 0xfffe80da5e10> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80da5e10> 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 0xfffe80da5050> 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 0xfffe80da5dc0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80da5dc0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_subclass_with_attribute at 0xfffe81998ad0> 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 0xfffe80dcd290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80d28c10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_subclass_with_attribute() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_subclass_with_attribute E module = self.import_module(name='array') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_subclass_with_attribute() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_subclass_with_attribute module = self.import_module(name='array') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestBoolMacros.test_macros _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe811189d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe810c6640> 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 0xfffe810c6b40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810c6b40> 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 0xfffe810c6cd0> 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 0xfffe810c6500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810c6500> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_macros at 0xfffe819d0cd0> 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 0xfffe8109c310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109cf90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> E test_macros() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_macros E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> test_macros() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_macros module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestBoolMacros.test_toint _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f4a250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe811329b0> 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 0xfffe81132960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe81132960> 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 0xfffe811322d0> 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 0xfffe81132fa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe81132fa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_toint at 0xfffe819d0d50> 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 0xfffe80e75150>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e75510> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_toint() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_toint E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_toint() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_toint module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestBoolMacros.test_check _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f2b8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80cfd2d0> 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 0xfffe80cfd6e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cfd6e0> 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 0xfffe80cfd280> 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 0xfffe80d437d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80d437d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_check at 0xfffe819d0dd0> 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 0xfffe80e75dd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e750d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_check() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_check E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_check() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_check module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestBorrow.test_tuple_borrowing ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f4a650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80cfd8c0> 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 0xfffe80f7dc30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f7dc30> 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 0xfffe80f7db40> 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 0xfffe811708c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe811708c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_tuple_borrowing at 0xfffe819cf350> 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 0xfffe80e75910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e75ad0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_tuple_borrowing() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_tuple_borrowing E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_tuple_borrowing() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_tuple_borrowing module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestBorrow.test_borrow_destroy _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f967d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80cb95a0> 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 0xfffe80cb9780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cb9780> 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 0xfffe80cb9870> 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 0xfffe80cb9910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cb9910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_borrow_destroy at 0xfffe819cf3d0> 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 0xfffe80e757d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e75710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_borrow_destroy() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_borrow_destroy E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_borrow_destroy() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_borrow_destroy module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestBorrow.test_double_borrow _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f4a650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e62f50> 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 0xfffe80e62b90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e62b90> 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 0xfffe80e628c0> 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 0xfffe80cb9230> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cb9230> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_double_borrow at 0xfffe819cf450> 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 0xfffe8109ced0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8109c9d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_double_borrow() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_double_borrow E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_double_borrow() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_double_borrow module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestBuffer.test_AsWriteBuffer _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f2b950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80cfd870> 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 0xfffe80cfd0f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cfd0f0> 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 0xfffe80cfd1e0> 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 0xfffe80cfd730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cfd730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_AsWriteBuffer at 0xfffe819cfd50> 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 0xfffe80ef2ed0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ef2c10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_AsWriteBuffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_AsWriteBuffer E module = self.import_extension('buffer', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_AsWriteBuffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_AsWriteBuffer module = self.import_extension('buffer', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestBuffer.test_mmap_buffer ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a7d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c63460> 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 0xfffe80c63550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c63550> 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 0xfffe80c635f0> 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 0xfffe80c636e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c636e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_mmap_buffer at 0xfffe819cfdd0> 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 0xfffe80f0d610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f0d6d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_mmap_buffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_mmap_buffer E module = self.import_extension('mmap_buffer', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_mmap_buffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_mmap_buffer module = self.import_extension('mmap_buffer', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestBuffer.test_applevel __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f2b950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80f7d4b0> 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 0xfffe80cfd1e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cfd1e0> 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 0xfffe80cfd9b0> 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 0xfffe80cfd5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80cfd5f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_applevel at 0xfffe819cfe50> 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 0xfffe80e75810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e75210> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_applevel() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_applevel E module = self.import_extension("foo", [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_applevel() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_applevel module = self.import_extension("foo", [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestBuffer.test_argparse __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f4a650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c71690> 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 0xfffe80c71910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c71910> 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 0xfffe80c71a00> 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 0xfffe80c71aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c71aa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_argparse at 0xfffe819cfed0> 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 0xfffe8109c990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe810a9fd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> E test_argparse() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_argparse E module = self.import_extension("foo", [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> test_argparse() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_argparse module = self.import_extension("foo", [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________ AppTestBuffer.test_bytearray_release_buffer_unlocks_resize __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f2b950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80f05190> 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 0xfffe80f05d70> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f05d70> 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 0xfffe80f05fa0> 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 0xfffe80c52230> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c52230> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytearray_release_buffer_unlocks_resize at 0xfffe819cff50> 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 0xfffe80d27e50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80d27f10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 161, in <module> E test_bytearray_release_buffer_unlocks_resize() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_bytearray_release_buffer_unlocks_resize E module = self.import_extension("foo", [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 161, in <module> test_bytearray_release_buffer_unlocks_resize() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_bytearray_release_buffer_unlocks_resize module = self.import_extension("foo", [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestStringObject.test_basic ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80fb11d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c52be0> 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 0xfffe80c52820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c52820> 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 0xfffe80c52690> 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 0xfffe80c52500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c52500> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_basic at 0xfffe819f08d0> 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 0xfffe80ce1350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f77f90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_basic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_basic E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_basic() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_basic module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestStringObject.test_bytearray_buffer_init ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8100a7d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c1e4b0> 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 0xfffe80c1e730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c1e730> 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 0xfffe80c1e820> 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 0xfffe80c1e8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c1e8c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytearray_buffer_init at 0xfffe819f0950> 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 0xfffe80f0d650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f0df10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_bytearray_buffer_init() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytearray_buffer_init E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_bytearray_buffer_init() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytearray_buffer_init module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestStringObject.test_bytearray_mutable __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80fb11d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c71d20> 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 0xfffe80dadfa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80dadfa0> 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 0xfffe80dad4b0> 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 0xfffe80dad5a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80dad5a0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytearray_mutable at 0xfffe819f09d0> 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 0xfffe80f0de90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f0dd90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_bytearray_mutable() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytearray_mutable E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_bytearray_mutable() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytearray_mutable module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestStringObject.test_AsByteArray _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f211d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c385a0> 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 0xfffe80c38820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c38820> 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 0xfffe80c38910> 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 0xfffe80c389b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c389b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_AsByteArray at 0xfffe819f0a50> 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 0xfffe80cfec50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80cc1110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test_AsByteArray() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsByteArray E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test_AsByteArray() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsByteArray module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestStringObject.test_manipulations ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80fb11d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80ce2460> 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 0xfffe80ce20a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ce20a0> 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 0xfffe80ce2e60> 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 0xfffe80ce2280> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ce2280> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_manipulations at 0xfffe819f0ad0> 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 0xfffe80c56290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80c56490> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 173, in <module> E test_manipulations() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_manipulations E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 173, in <module> test_manipulations() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_manipulations module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestStringObject.test_bytearray_resize ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f211d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c38870> 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 0xfffe80c380a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c380a0> 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 0xfffe80c38730> 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 0xfffe80c38780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c38780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytearray_resize at 0xfffe819f0b50> 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 0xfffe80f0dc10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f0dfd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 154, in <module> E test_bytearray_resize() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytearray_resize E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 154, in <module> test_bytearray_resize() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytearray_resize module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestBytesObject.test_bytesobject ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d5e050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80bdd500> 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 0xfffe80bdd5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdd5f0> 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 0xfffe80bdd690> 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 0xfffe80bdd780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdd780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytesobject at 0xfffe81a0dcd0> 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 0xfffe80f0db90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8115d210> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> E test_bytesobject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytesobject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> test_bytesobject() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytesobject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestBytesObject.test_bytes_buffer_init ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80dc2550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80f05cd0> 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 0xfffe80f052d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f052d0> 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 0xfffe80c52b90> 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 0xfffe80c52190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c52190> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytes_buffer_init at 0xfffe81a0dd50> 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 0xfffe80f0dd90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e5b6d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> E test_bytes_buffer_init() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytes_buffer_init E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> test_bytes_buffer_init() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytes_buffer_init module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestBytesObject.test_bytes_tp_alloc ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ca25d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80bdf730> 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 0xfffe80bdf960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdf960> 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 0xfffe80bdf9b0> 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 0xfffe80bdfaa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdfaa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bytes_tp_alloc at 0xfffe81a0ddd0> 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 0xfffe80c56b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80c56e10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> E test_bytes_tp_alloc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytes_tp_alloc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> test_bytes_tp_alloc() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_bytes_tp_alloc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestBytesObject.test_AsString _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80dc9050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80bdf460> 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 0xfffe80f8c1e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f8c1e0> 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 0xfffe80f8c500> 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 0xfffe80f8c370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f8c370> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_AsString at 0xfffe81a0de50> 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 0xfffe80e5ba50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e5bd50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_AsString() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsString E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_AsString() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsString module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestBytesObject.test_manipulations _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c90950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b9f7d0> 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 0xfffe80b9fa50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b9fa50> 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 0xfffe80b9fb40> 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 0xfffe80b9fbe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b9fbe0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_manipulations at 0xfffe81a0ded0> 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 0xfffe810a8b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80c1b450> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_manipulations() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_manipulations E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_manipulations() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_manipulations module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestBytesObject.test_py_bytes_as_string_None ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80dc9050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80db43c0> 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 0xfffe80c29960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c29960> 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 0xfffe80c29be0> 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 0xfffe80f050f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f050f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_py_bytes_as_string_None at 0xfffe81a0df50> 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 0xfffe8115da10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8115df10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_py_bytes_as_string_None() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_py_bytes_as_string_None E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_py_bytes_as_string_None() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_py_bytes_as_string_None module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestBytesObject.test_AsStringAndSize ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c90950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80ba2870> 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 0xfffe80ba2a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ba2a50> 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 0xfffe80ba2b40> 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 0xfffe80ba2be0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ba2be0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_AsStringAndSize at 0xfffe818d6050> 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 0xfffe80be5f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80be5510> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 164, in <module> E test_AsStringAndSize() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsStringAndSize E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 164, in <module> test_AsStringAndSize() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsStringAndSize module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestBytesObject.test_FromFormat ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d5e050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b916e0> 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 0xfffe80b918c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b918c0> 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 0xfffe80b919b0> 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 0xfffe80b91a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b91a50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_FromFormat at 0xfffe818d60d0> 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 0xfffe80ca74d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ca7350> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_FromFormat() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromFormat E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_FromFormat() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromFormat module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestBytesObject.test_suboffsets ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cfb7d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b91500> 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 0xfffe80f6b820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f6b820> 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 0xfffe80f6b410> 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 0xfffe80f6b0f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80f6b0f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_suboffsets at 0xfffe818d6150> 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 0xfffe80ba5e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ba5f10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_suboffsets() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_suboffsets E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_suboffsets() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_suboffsets module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestCapsule.test_capsule_import ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f00850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b6f690> 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 0xfffe80b6f780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b6f780> 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 0xfffe80b6f820> 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 0xfffe80b6f910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b6f910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_capsule_import at 0xfffe818d6bd0> 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 0xfffe80ba5d10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ba5b90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_capsule_import() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_capsule_import E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_capsule_import() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_capsule_import module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestCapsule.test_capsule_set ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ca2f50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b912d0> 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 0xfffe8114c500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8114c500> 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 0xfffe8114c730> 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 0xfffe8114c550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8114c550> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_capsule_set at 0xfffe818d6c50> 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 0xfffe80c1b790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80c18b50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 214, in <module> E test_capsule_set() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_capsule_set E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 214, in <module> test_capsule_set() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_capsule_set module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________ AppTestCapsule.test_capsule_destructor_via_gc_collect _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80f00850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b6f370> 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 0xfffe80b6f820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b6f820> 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 0xfffe80b6feb0> 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 0xfffe80b6fc30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b6fc30> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_capsule_destructor_via_gc_collect at 0xfffe818d6cd0> 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 0xfffe80ca7990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80c1ba90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 197, in <module> E test_capsule_destructor_via_gc_collect() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_capsule_destructor_via_gc_collect E module = self.import_extension('foo_cap_gc', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 197, in <module> test_capsule_destructor_via_gc_collect() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_capsule_destructor_via_gc_collect module = self.import_extension('foo_cap_gc', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestCell.test_cell_type __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ca23d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80bdfaa0> 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 0xfffe80bdf280> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdf280> 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 0xfffe80bdfe10> 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 0xfffe80bdf910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdf910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_cell_type at 0xfffe818e89d0> 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 0xfffe80f72f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f72c90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test_cell_type() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_cell_type E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test_cell_type() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_cell_type module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestInstanceMethod.test_instancemethod ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ee8150>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80ba18c0> 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 0xfffe80ba1960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ba1960> 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 0xfffe80ba19b0> 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 0xfffe80ba1a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ba1a50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_instancemethod at 0xfffe818ec150> 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 0xfffe80f72cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f72a10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_instancemethod() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_instancemethod E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_instancemethod() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_instancemethod module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________ AppTestInstanceMethod.test_instancemethod_cpyext_attributes __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe811199d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b408c0> 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 0xfffe80b409b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b409b0> 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 0xfffe80b40a50> 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 0xfffe80b40b40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b40b40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_instancemethod_cpyext_attributes at 0xfffe818ec1d0> 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 0xfffe80c1bb90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ba5f10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> E test_instancemethod_cpyext_attributes() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_instancemethod_cpyext_attributes E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> test_instancemethod_cpyext_attributes() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_instancemethod_cpyext_attributes module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestUnicodeObject.test_encode_decode ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe811193d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80f8c5a0> 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 0xfffe80b6f2d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b6f2d0> 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 0xfffe80b6fcd0> 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 0xfffe80b6feb0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b6feb0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_encode_decode at 0xfffe818fa650> 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 0xfffe80e6d850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80bbd710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_encode_decode() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_encode_decode E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_encode_decode() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_encode_decode module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestCComplex.test_AsCComplex ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80eea750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c59050> 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 0xfffe80c59e10> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c59e10> 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 0xfffe80c59780> 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 0xfffe80c59af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c59af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_AsCComplex at 0xfffe8190e450> 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 0xfffe80b65050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80b65b50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_AsCComplex() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsCComplex E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_AsCComplex() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_AsCComplex module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestCComplex.test_FromCComplex _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80bb6150>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b44730> 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 0xfffe80b447d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b447d0> 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 0xfffe80b448c0> 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 0xfffe80b44820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b44820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_FromCComplex at 0xfffe8190e4d0> 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 0xfffe80b59fd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80b59390> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_FromCComplex() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromCComplex E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_FromCComplex() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromCComplex module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCComplex.test_PyComplex_to_WComplex __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80eea750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe818d1b90> 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 0xfffe80be0eb0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80be0eb0> 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 0xfffe80be0320> 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 0xfffe80be0370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80be0370> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyComplex_to_WComplex at 0xfffe8190e550> 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 0xfffe80b650d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80bbd250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_PyComplex_to_WComplex() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyComplex_to_WComplex E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_PyComplex_to_WComplex() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyComplex_to_WComplex module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCComplex.test_WComplex_to_PyComplex __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d01bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80ae7730> 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 0xfffe80ae7780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ae7780> 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 0xfffe80ae7870> 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 0xfffe80ae7910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80ae7910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_WComplex_to_PyComplex at 0xfffe8190e5d0> 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 0xfffe80f72f10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80b59650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_WComplex_to_PyComplex() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_WComplex_to_PyComplex E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_WComplex_to_PyComplex() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_WComplex_to_PyComplex module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCComplex.test_PyComplex_AsCComplex ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80eea750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8111d5f0> 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 0xfffe8111d050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8111d050> 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 0xfffe8111d140> 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 0xfffe80aff8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aff8c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyComplex_AsCComplex at 0xfffe8190e650> 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 0xfffe80b271d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f72390> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_PyComplex_AsCComplex() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyComplex_AsCComplex E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_PyComplex_AsCComplex() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyComplex_AsCComplex module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestContext.test_context __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d01750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b04820> 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 0xfffe80b04870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b04870> 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 0xfffe80b04960> 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 0xfffe80b04a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b04a00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_context at 0xfffe8190e8d0> 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 0xfffe80b65c10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e6d0d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 249, in <module> E test_context() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_context E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 249, in <module> test_context() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_context module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCpythonExtension.test_createmodule ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d01bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b2bcd0> 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 0xfffe80b2b5a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b2b5a0> 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 0xfffe80b2b410> 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 0xfffe80b2b5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b2b5f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_createmodule at 0xfffe81a3db50> 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 0xfffe80ae3310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ae35d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in <module> E test_createmodule() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_createmodule E self.import_module(name='foo') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in <module> test_createmodule() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_createmodule self.import_module(name='foo') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestCpythonExtension.test_export_function _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdfc50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8116f3c0> 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 0xfffe8116f0a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8116f0a0> 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 0xfffe8116fd70> 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 0xfffe8116f1e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8116f1e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_function at 0xfffe81a3dbd0> 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 0xfffe80e6d0d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80f72c90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_export_function() E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in test_export_function E module = self.import_module(name='foo', body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_export_function() File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in test_export_function module = self.import_module(name='foo', body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestCpythonExtension.test_export_docstring _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d06250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8195ef00> 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 0xfffe80b2b5a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b2b5a0> 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 0xfffe80b2b780> 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 0xfffe80b2b410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b2b410> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_docstring at 0xfffe81a3dc50> 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 0xfffe80b0d510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80b0d210> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_export_docstring() E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test_export_docstring E module = self.import_module(name='foo', body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_export_docstring() File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test_export_docstring module = self.import_module(name='foo', body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCpythonExtension.test_load_dynamic ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdfd50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80aae910> 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 0xfffe80aaea00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aaea00> 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 0xfffe80aaeaa0> 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 0xfffe80aaeb90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aaeb90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_load_dynamic at 0xfffe81a3dcd0> 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 0xfffe80ae3cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ae3550> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_load_dynamic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_load_dynamic E foo = self.import_module(name='foo', body=body, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_load_dynamic() File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_load_dynamic foo = self.import_module(name='foo', body=body, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestCpythonExtension.test_InitModule4_dotted ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80b16650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b3e2d0> 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 0xfffe80b3e8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b3e8c0> 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 0xfffe80b3e5f0> 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 0xfffe80b40f00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b40f00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_InitModule4_dotted at 0xfffe81a3dd50> 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 0xfffe80b0d2d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80b0d610> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_InitModule4_dotted() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_InitModule4_dotted E module = self.import_module(name=expected_name, filename="dotted") E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_InitModule4_dotted() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_InitModule4_dotted module = self.import_module(name=expected_name, filename="dotted") ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________ AppTestCpythonExtension.test_InitModule4_in_package ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdfd50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80a15690> 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 0xfffe80a158c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a158c0> 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 0xfffe80a15910> 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 0xfffe80a15a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a15a00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_InitModule4_in_package at 0xfffe81a3ddd0> 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 0xfffe80b18750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80b18810> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_InitModule4_in_package() E File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_InitModule4_in_package E module = self.import_module(name="apple.banana", filename="banana") E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_InitModule4_in_package() File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_InitModule4_in_package module = self.import_module(name="apple.banana", filename="banana") ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________ AppTestCpythonExtension.test_recursive_package_import _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80b16650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80aae230> 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 0xfffe80aae410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aae410> 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 0xfffe80aae1e0> 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 0xfffe80aaeb90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aaeb90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_recursive_package_import at 0xfffe81a3de50> 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 0xfffe8115a790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8115a4d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_recursive_package_import() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_recursive_package_import E banana = self.compile_module( E ^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 77, in w_compile_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_recursive_package_import() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_recursive_package_import banana = self.compile_module( ^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 77, in w_compile_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCpythonExtension.test_modinit_func ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80b6d8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80a2f5a0> 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 0xfffe80a2f820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a2f820> 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 0xfffe80a2f910> 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 0xfffe80a2f9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a2f9b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_modinit_func at 0xfffe81a3ded0> 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 0xfffe81174950>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e6d9d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> E test_modinit_func() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_modinit_func E module = self.import_module(name='modinit') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> test_modinit_func() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_modinit_func module = self.import_module(name='modinit') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestCpythonExtension.test_export_function2 _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80af0c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80bdc320> 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 0xfffe80bdcfa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdcfa0> 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 0xfffe80bdc050> 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 0xfffe80bdc730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bdc730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_function2 at 0xfffe81a3df50> 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 0xfffe80c6e590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80c6e090> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 168, in <module> E test_export_function2() E File "/tmp/pytest/usession-py3.12-228/src.py", line 158, in test_export_function2 E module = self.import_module(name='foo', body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 168, in <module> test_export_function2() File "/tmp/pytest/usession-py3.12-228/src.py", line 158, in test_export_function2 module = self.import_module(name='foo', body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestCpythonExtension.test_argument _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d061d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80a2f820> 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 0xfffe80a2f4b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a2f4b0> 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 0xfffe80a2f910> 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 0xfffe80a2ffa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a2ffa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_argument at 0xfffe81a45050> 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 0xfffe80ae3910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe81174890> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_argument() E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in test_argument E module = self.import_module(name='foo', body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_argument() File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in test_argument module = self.import_module(name='foo', body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestCpythonExtension.test_exception ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80af0c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80ae19b0> 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 0xfffe80b711e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b711e0> 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 0xfffe80b715a0> 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 0xfffe80bfbc80> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bfbc80> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_exception at 0xfffe81a450d0> 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 0xfffe80a4ba10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80ae3250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_exception() E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in test_exception E module = self.import_module(name='foo', body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_exception() File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in test_exception module = self.import_module(name='foo', body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestCpythonExtension.test_refcount _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdfe50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80bda780> 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 0xfffe80bda730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bda730> 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 0xfffe80bda7d0> 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 0xfffe80bda870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80bda870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_refcount at 0xfffe81a45150> 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 0xfffe80c6e790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8115ad50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 174, in <module> E test_refcount() E File "/tmp/pytest/usession-py3.12-228/src.py", line 170, in test_refcount E module = self.import_module(name='foo', body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 174, in <module> test_refcount() File "/tmp/pytest/usession-py3.12-228/src.py", line 170, in test_refcount module = self.import_module(name='foo', body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestCpythonExtension.test_init_exception __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d06250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80abf7d0> 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 0xfffe80b71370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b71370> 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 0xfffe80b71b40> 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 0xfffe80b71230> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b71230> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_init_exception at 0xfffe81a451d0> 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 0xfffe80ae3450>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a16dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_init_exception() E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in test_init_exception E raise exc.value E File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises E func(*args, **kwargs) E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_init_exception() File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in test_init_exception raise exc.value File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises func(*args, **kwargs) File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCpythonExtension.test_new_exception __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d06bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c20d70> 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 0xfffe80aed6e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aed6e0> 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 0xfffe80aed780> 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 0xfffe80b71050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b71050> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_new_exception at 0xfffe81a452d0> 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 0xfffe80a1f110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a1f210> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_new_exception() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_new_exception E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_new_exception() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_new_exception mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestCpythonExtension.test_types ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdfc50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80b3ebe0> 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 0xfffe80a92190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a92190> 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 0xfffe80a92f00> 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 0xfffe80a92e10> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a92e10> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_types at 0xfffe81a453d0> 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 0xfffe80a8d090>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a8d550> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_types() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_types E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_types() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_types mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestCpythonExtension.test_get_programname _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c537d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80c0ae60> 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 0xfffe80c0afa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c0afa0> 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 0xfffe80c0ad70> 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 0xfffe80c0af50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c0af50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_get_programname at 0xfffe81a45450> 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 0xfffe80c6e250>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a8d110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_get_programname() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_programname E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_get_programname() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_programname mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestCpythonExtension.test_no_double_imports ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c530d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e531e0> 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 0xfffe80e53e60> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80e53e60> 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 0xfffe80c20960> 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 0xfffe80c20050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c20050> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_no_double_imports at 0xfffe81a45550> 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 0xfffe80a671d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a672d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 167, in <module> E test_no_double_imports() E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in test_no_double_imports E self.import_module(name='foo', init=init, body=body) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 167, in <module> test_no_double_imports() File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in test_no_double_imports self.import_module(name='foo', init=init, body=body) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestCpythonExtension.test_no_structmember _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c6d1d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809d4230> 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 0xfffe809d45a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809d45a0> 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 0xfffe809d4690> 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 0xfffe809d4730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809d4730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_no_structmember at 0xfffe81a455d0> 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 0xfffe80a1f7d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a1f750> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_no_structmember() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_no_structmember E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_no_structmember() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_no_structmember mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestCpythonExtension.test_consistent_flags _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80e59cd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80aff730> 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 0xfffe80aff9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80aff9b0> 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 0xfffe80b71690> 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 0xfffe80b71140> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80b71140> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_consistent_flags at 0xfffe81a45650> 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 0xfffe80ae3590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a8d250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_consistent_flags() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_consistent_flags E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_consistent_flags() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_consistent_flags mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCpythonExtension.test_generic_type ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80d06250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80a39190> 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 0xfffe80c3e780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c3e780> 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 0xfffe80c3e910> 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 0xfffe80c3eaa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80c3eaa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_generic_type at 0xfffe81a456d0> 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 0xfffe80a8d610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a76e50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_generic_type() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_generic_type E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_generic_type() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_generic_type mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestDatetime.test_CAPI ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdf650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80a39b90> 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 0xfffe80a39640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a39640> 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 0xfffe80a394b0> 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 0xfffe80a39320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80a39320> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_CAPI at 0xfffe81981650> 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 0xfffe80a8d210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a8d850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 155, in <module> E test_CAPI() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CAPI E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 155, in <module> test_CAPI() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CAPI module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestDatetime.test_constructors _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c324d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809bc6e0> 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 0xfffe809bc7d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809bc7d0> 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 0xfffe809bc870> 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 0xfffe809bc960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809bc960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_constructors at 0xfffe819816d0> 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 0xfffe80a50710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a16dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 191, in <module> E test_constructors() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_constructors E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 191, in <module> test_constructors() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_constructors module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestDatetime.test_timezone_constructors __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80cdf650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809cc690> 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 0xfffe809cc780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809cc780> 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 0xfffe809cc820> 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 0xfffe809cc910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809cc910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_timezone_constructors at 0xfffe81981750> 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 0xfffe809ebe50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a8d810> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> E test_timezone_constructors() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_timezone_constructors E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> test_timezone_constructors() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_timezone_constructors module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestDatetime.test_macros __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c324d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe81095820> 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 0xfffe810955a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe810955a0> 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 0xfffe810957d0> 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 0xfffe81095c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe81095c30> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_macros at 0xfffe819817d0> 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 0xfffe80a504d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a8d590> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 243, in <module> E test_macros() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_macros E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 243, in <module> test_macros() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_macros module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestDatetime.test_tzinfo __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c79dd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809f50a0> 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 0xfffe809f5190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809f5190> 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 0xfffe809f51e0> 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 0xfffe809f56e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809f56e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_tzinfo at 0xfffe81981850> 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 0xfffe809eb450>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80a7cbd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 171, in <module> E test_tzinfo() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_tzinfo E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 171, in <module> test_tzinfo() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_tzinfo module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestDatetime.test_checks __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c324d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809ccd70> 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 0xfffe809cc0a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809cc0a0> 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 0xfffe809cc1e0> 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 0xfffe809cc2d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809cc2d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_checks at 0xfffe819818d0> 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 0xfffe80e86b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e86dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 150, in <module> E test_checks() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_checks E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 150, in <module> test_checks() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_checks module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestDatetime.test_misc ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c79dd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80978780> 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 0xfffe80978a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80978a00> 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 0xfffe80978af0> 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 0xfffe80978b90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80978b90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_misc at 0xfffe81981950> 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 0xfffe80a7cd10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe809b7dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_misc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_misc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_misc() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_misc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestDictObject.test_dictproxytype _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80e59bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809bcfa0> 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 0xfffe809bc780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809bc780> 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 0xfffe809bc7d0> 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 0xfffe809bc230> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809bc230> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_dictproxytype at 0xfffe819889d0> 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 0xfffe80e86890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe809d11d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> E test_dictproxytype() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_dictproxytype E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> test_dictproxytype() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_dictproxytype module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestDictObject.test_getitemwitherror ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80c3dd50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809f5d70> 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 0xfffe809f55a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809f55a0> 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 0xfffe809f5140> 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 0xfffe809f56e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809f56e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getitemwitherror at 0xfffe81988a50> 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 0xfffe80990310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e86d90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 157, in <module> E test_getitemwitherror() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getitemwitherror E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 157, in <module> test_getitemwitherror() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getitemwitherror module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestDictObject.test_setdefault _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80e59bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808fb640> 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 0xfffe808fb730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808fb730> 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 0xfffe808fb7d0> 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 0xfffe808fb8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808fb8c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_setdefault at 0xfffe81988ad0> 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 0xfffe809b7890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80e86c50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_setdefault() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_setdefault E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_setdefault() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_setdefault module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestDictObject.test_update _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe809fa0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe809a7640> 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 0xfffe809a8b90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809a8b90> 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 0xfffe809a8f50> 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 0xfffe809a8910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809a8910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_update at 0xfffe81988b50> 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 0xfffe80980910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80980110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_update() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_update E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_update() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_update module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestDictObject.test_iter __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe810be8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808e13c0> 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 0xfffe808e15a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808e15a0> 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 0xfffe808e1690> 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 0xfffe808e1730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808e1730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_iter at 0xfffe81988bd0> 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 0xfffe8097b7d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8097b650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 142, in <module> E test_iter() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iter E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 142, in <module> test_iter() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iter module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestDictObject.test_iterkeys ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe809fa0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80987280> 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 0xfffe80987af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80987af0> 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 0xfffe80987a00> 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 0xfffe80987dc0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80987dc0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_iterkeys at 0xfffe81988c50> 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 0xfffe809514d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe809510d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_iterkeys() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iterkeys E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_iterkeys() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iterkeys module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestDictObject.test_typedict2 _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8091c2d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8090daa0> 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 0xfffe8090db90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8090db90> 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 0xfffe8090dc30> 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 0xfffe8090dd20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8090dd20> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_typedict2 at 0xfffe81988cd0> 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 0xfffe8097bf50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8097b750> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_typedict2() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_typedict2 E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_typedict2() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_typedict2 module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestDictObject.test_advanced ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe809fa0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808e1730> 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 0xfffe808e13c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808e13c0> 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 0xfffe808e1e60> 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 0xfffe80983fa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80983fa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_advanced at 0xfffe81988d50> 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 0xfffe808f8cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808f8d10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 187, in <module> E test_advanced() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_advanced E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 187, in <module> test_advanced() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_advanced module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestDictObject.test_subclassing ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe810ba550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8096a730> 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 0xfffe8096a410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8096a410> 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 0xfffe8096a640> 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 0xfffe8096a3c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8096a3c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_subclassing at 0xfffe81988dd0> 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 0xfffe809b7950>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe809b75d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 184, in <module> E test_subclassing() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_subclassing E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 184, in <module> test_subclassing() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_subclassing module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestDictObject.test_getitem_error _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8091cc50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80e65c80> 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 0xfffe809553c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809553c0> 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 0xfffe80955050> 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 0xfffe808eebe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808eebe0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getitem_error at 0xfffe81988e50> 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 0xfffe808fa710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808fa8d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test_getitem_error() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getitem_error E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test_getitem_error() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getitem_error module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestDictObject.test_contains ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80acbbd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808b5550> 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 0xfffe808b55f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808b55f0> 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 0xfffe808b56e0> 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 0xfffe808b5820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808b5820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_contains at 0xfffe81988ed0> 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 0xfffe808fa390>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8097bb10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> E test_contains() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_contains E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> test_contains() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_contains module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestCall.test_CallFunction _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80e64650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808ca8c0> 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 0xfffe808ca910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808ca910> 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 0xfffe808caa00> 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 0xfffe808caaa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808caaa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_CallFunction at 0xfffe818ad9d0> 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 0xfffe808ec910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808ec2d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_CallFunction() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CallFunction E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_CallFunction() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CallFunction module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestCall.test_CallFunction_PY_SSIZE_T_CLEAN ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ab1450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8090caa0> 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 0xfffe8090c9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8090c9b0> 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 0xfffe8090cd20> 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 0xfffe8090cf50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8090cf50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_CallFunction_PY_SSIZE_T_CLEAN at 0xfffe818ada50> 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 0xfffe808d0c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808d0b90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> E test_CallFunction_PY_SSIZE_T_CLEAN() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CallFunction_PY_SSIZE_T_CLEAN E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> test_CallFunction_PY_SSIZE_T_CLEAN() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CallFunction_PY_SSIZE_T_CLEAN module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestCall.test_CallFunctionObjArgs _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80e64650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808ce7d0> 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 0xfffe808cea00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808cea00> 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 0xfffe808cea50> 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 0xfffe808ceb40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808ceb40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_CallFunctionObjArgs at 0xfffe818adad0> 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 0xfffe808f34d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808f3450> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 191, in <module> E test_CallFunctionObjArgs() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CallFunctionObjArgs E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 191, in <module> test_CallFunctionObjArgs() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_CallFunctionObjArgs module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestCall.test_CompileString_and_Exec ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80aea4d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe808b8690> 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 0xfffe808b8910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808b8910> 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 0xfffe808b8a00> 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 0xfffe808b8aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808b8aa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_CompileString_and_Exec at 0xfffe818adb50> 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 0xfffe80949290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80949110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> E test_CompileString_and_Exec() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_CompileString_and_Exec E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> test_CompileString_and_Exec() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_CompileString_and_Exec module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestCall.test_merge_compiler_flags _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ab1d50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80814460> 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 0xfffe808144b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808144b0> 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 0xfffe808145a0> 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 0xfffe80814640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80814640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_merge_compiler_flags at 0xfffe818adbd0> 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 0xfffe8093fb10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808f36d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_merge_compiler_flags() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_merge_compiler_flags E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_merge_compiler_flags() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_merge_compiler_flags module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestCall.test_recursive_function ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808c5c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8083ba00> 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 0xfffe8083baa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083baa0> 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 0xfffe8083ba50> 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 0xfffe8083bb90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083bb90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_recursive_function at 0xfffe818adc50> 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 0xfffe808d0d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808e5810> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> E test_recursive_function() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_recursive_function E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> test_recursive_function() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_recursive_function module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestCall.test_build_class _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ab1d50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80832460> 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 0xfffe80832550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80832550> 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 0xfffe808325f0> 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 0xfffe808326e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808326e0> 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-aarch64/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 0xfffe808f3710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808cc550> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 256, in <module> E test_build_class() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_build_class E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 256, in <module> test_build_class() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_build_class module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestCall.test_getframe ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80900bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8083e4b0> 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 0xfffe8083e5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083e5f0> 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 0xfffe8083e550> 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 0xfffe8083e870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083e870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getframe at 0xfffe818add50> 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 0xfffe808b7390>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808b7150> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> E test_getframe() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_getframe E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in <module> test_getframe() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_getframe module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestCall.test_getbuiltins _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80ab1d50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80838780> 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 0xfffe80838a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80838a00> 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 0xfffe80838af0> 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 0xfffe80838b90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80838b90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getbuiltins at 0xfffe818addd0> 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 0xfffe808ccb10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808cc8d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_getbuiltins() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getbuiltins E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_getbuiltins() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getbuiltins module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestExceptions.test_OSError_aliases ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe810ba5d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80941d20> 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 0xfffe8083ecd0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083ecd0> 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 0xfffe8083e5f0> 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 0xfffe8083eb40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083eb40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_OSError_aliases at 0xfffe818c3e50> 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 0xfffe8092a4d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8092a650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_OSError_aliases() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_OSError_aliases E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_OSError_aliases() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_OSError_aliases module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestExceptions.test_implicit_chaining ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808efdd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80869870> 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 0xfffe80869960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80869960> 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 0xfffe80869a00> 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 0xfffe80869af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80869af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_implicit_chaining at 0xfffe818c3ed0> 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 0xfffe808cc790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808ccb90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 142, in <module> E test_implicit_chaining() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_implicit_chaining E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 142, in <module> test_implicit_chaining() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_implicit_chaining module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestFileObject.test_defaultencoding ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe810ba5d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8083bb90> 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 0xfffe8083b730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083b730> 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 0xfffe8083b550> 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 0xfffe8083b780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083b780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_defaultencoding at 0xfffe818c71d0> 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 0xfffe809b1890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8089fcd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_defaultencoding() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_defaultencoding E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_defaultencoding() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_defaultencoding module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestFloatObject.test_fromstring ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80acbbd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80aa5dc0> 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 0xfffe809098c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809098c0> 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 0xfffe80909280> 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 0xfffe809093c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809093c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromstring at 0xfffe8186a8d0> 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 0xfffe8082e790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8082e590> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_fromstring() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromstring E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_fromstring() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromstring module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestFloatObject.test_return_nan ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a75950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807c43c0> 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 0xfffe807c4640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807c4640> 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 0xfffe807c46e0> 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 0xfffe807c47d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807c47d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_return_nan at 0xfffe8186a950> 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 0xfffe8082e5d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808ccd90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_return_nan() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_return_nan E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_return_nan() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_return_nan module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestFloatObject.test_return_inf ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a60850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8185e140> 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 0xfffe808ce550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808ce550> 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 0xfffe809c7d20> 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 0xfffe809c79b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe809c79b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_return_inf at 0xfffe8186a9d0> 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 0xfffe808cc2d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80815110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_return_inf() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_return_inf E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_return_inf() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_return_inf module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestFloatObject.test_return_inf_negative __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a60550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807b5870> 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 0xfffe807b5960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807b5960> 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 0xfffe807b5a00> 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 0xfffe807b5af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807b5af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_return_inf_negative at 0xfffe8186aa50> 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 0xfffe8082e7d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8082e4d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_return_inf_negative() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_return_inf_negative E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_return_inf_negative() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_return_inf_negative module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________ AppTestFloatObject.test_macro_accepts_wrong_pointer_type ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a759d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8094cc30> 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 0xfffe8094cb40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8094cb40> 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 0xfffe8094cf50> 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 0xfffe8094c550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8094c550> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_macro_accepts_wrong_pointer_type at 0xfffe8186aad0> 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 0xfffe80815510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80815b90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_macro_accepts_wrong_pointer_type() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_macro_accepts_wrong_pointer_type E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_macro_accepts_wrong_pointer_type() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_macro_accepts_wrong_pointer_type module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestFloatObject.test_PyFloat_Check _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80acbbd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8087b140> 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 0xfffe8090f3c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8090f3c0> 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 0xfffe8083b640> 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 0xfffe8083bb90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8083bb90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyFloat_Check at 0xfffe8186ab50> 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 0xfffe8082eb50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80815810> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_PyFloat_Check() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyFloat_Check E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_PyFloat_Check() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyFloat_Check module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestFloatObject.test_pymath_consts _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a60050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807f8640> 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 0xfffe807f86e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807f86e0> 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 0xfffe807f87d0> 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 0xfffe807f8730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807f8730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pymath_consts at 0xfffe8186abd0> 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 0xfffe80815dd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80815910> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_pymath_consts() E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_pymath_consts E module = self.import_extension('foo_%s' % const_name, [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_pymath_consts() File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_pymath_consts module = self.import_extension('foo_%s' % const_name, [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestFloatObject.test_Py_IS _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807ec2d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807b6fa0> 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 0xfffe807b5af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807b5af0> 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 0xfffe807b5f00> 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 0xfffe807b56e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807b56e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Py_IS at 0xfffe8186ac50> 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 0xfffe8082ec50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe808cc910> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> E test_Py_IS() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_Py_IS E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> test_Py_IS() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_Py_IS module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestFloatObject.test_Py_Float_AsDouble ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8092c0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80936730> 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 0xfffe80936780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80936780> 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 0xfffe809368c0> 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 0xfffe80936500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80936500> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Py_Float_AsDouble at 0xfffe8186acd0> 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 0xfffe807adad0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807ad350> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_Py_Float_AsDouble() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_Py_Float_AsDouble E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_Py_Float_AsDouble() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_Py_Float_AsDouble module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestFloatObject.test_Py_HUGE_VAL ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a60850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807f3730> 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 0xfffe807f37d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807f37d0> 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 0xfffe807f38c0> 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 0xfffe807f3820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807f3820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Py_HUGE_VAL at 0xfffe8186ad50> 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 0xfffe807ad450>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80815c10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_Py_HUGE_VAL() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_Py_HUGE_VAL E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_Py_HUGE_VAL() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_Py_HUGE_VAL module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestFloatObject.test_Py_NAN ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a751d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80a66a00> 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 0xfffe808353c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808353c0> 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 0xfffe80835410> 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 0xfffe808248c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe808248c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Py_NAN at 0xfffe8186add0> 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 0xfffe80868a10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80868310> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test_Py_NAN() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_Py_NAN E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test_Py_NAN() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_Py_NAN module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestFloatObject.test_roundtrip _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80929bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806d7500> 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 0xfffe806d75a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806d75a0> 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 0xfffe806d7690> 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 0xfffe806d77d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806d77d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_roundtrip at 0xfffe8186ae50> 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 0xfffe80868590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807b09d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 225, in <module> E test_roundtrip() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_roundtrip E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 225, in <module> test_roundtrip() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_roundtrip module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestFrameObject.test_forge_frame ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a60250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806d2640> 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 0xfffe806d2730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806d2730> 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 0xfffe806d27d0> 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 0xfffe806d28c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806d28c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_forge_frame at 0xfffe8186c8d0> 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 0xfffe807fed90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807fead0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 189, in <module> E test_forge_frame() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_forge_frame E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 189, in <module> test_forge_frame() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_forge_frame module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestFrameObject.test_forge_frame_newer ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806df8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806f3500> 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 0xfffe806f35f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806f35f0> 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 0xfffe806f3690> 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 0xfffe806f3780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806f3780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_forge_frame_newer at 0xfffe8186c950> 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 0xfffe807fe390>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807fe8d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 157, in <module> E test_forge_frame_newer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_forge_frame_newer E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 157, in <module> test_forge_frame_newer() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_forge_frame_newer module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestFrameObject.test_traceback_check ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a60250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806fd780> 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 0xfffe806fd960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806fd960> 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 0xfffe806fda50> 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 0xfffe806fdaf0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806fdaf0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_traceback_check at 0xfffe8186c9d0> 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 0xfffe808681d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8080e4d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 155, in <module> E test_traceback_check() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_traceback_check E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 155, in <module> test_traceback_check() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_traceback_check module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestFrameObject.test_get_xxx ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806df3d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8076b500> 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 0xfffe8076b460> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8076b460> 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 0xfffe8076b5a0> 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 0xfffe8076b640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8076b640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_get_xxx at 0xfffe8186ca50> 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 0xfffe807fef90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807fe090> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 197, in <module> E test_get_xxx() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_xxx E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 197, in <module> test_get_xxx() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_xxx module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______ AppTestPickleCpyextFunction.test_pickle_cpyext_function_directly _______ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80a759d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806d74b0> 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 0xfffe806d7410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806d7410> 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 0xfffe806d7cd0> 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 0xfffe806d7d20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806d7d20> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pickle_cpyext_function_directly at 0xfffe8188c0d0> 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 0xfffe807fa610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807fa8d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> E test_pickle_cpyext_function_directly() E File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_pickle_cpyext_function_directly E module = self.import_extension('pickle_cpyext_test', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> test_pickle_cpyext_function_directly() File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_pickle_cpyext_function_directly module = self.import_extension('pickle_cpyext_test', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___ AppTestPickleCpyextFunction.test_pickle_reduce_returning_cpyext_function ___ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808c2350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8078c780> 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 0xfffe8078c870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8078c870> 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 0xfffe8078c910> 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 0xfffe8078ca00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8078ca00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pickle_reduce_returning_cpyext_function at 0xfffe8188c150> 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 0xfffe807fa910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807f2f50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_pickle_reduce_returning_cpyext_function() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_reduce_returning_cpyext_function E module = self.import_extension('pickle_cpyext_reduce_test', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_pickle_reduce_returning_cpyext_function() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_reduce_returning_cpyext_function module = self.import_extension('pickle_cpyext_reduce_test', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________ AppTestPickleCpyextFunction.test_pickle_method_descriptor ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808a44d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807615f0> 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 0xfffe80761870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80761870> 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 0xfffe80761960> 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 0xfffe80761a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80761a00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pickle_method_descriptor at 0xfffe8188c1d0> 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 0xfffe8080e850>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80704dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> E test_pickle_method_descriptor() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_method_descriptor E module = self.import_extension('pickle_method_desc', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> test_pickle_method_descriptor() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_method_descriptor module = self.import_extension('pickle_method_desc', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________ AppTestPickleCpyextFunction.test_pickle_classmethod_descriptor ________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808c23d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807560a0> 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 0xfffe80756190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80756190> 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 0xfffe80756870> 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 0xfffe80756b90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80756b90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pickle_classmethod_descriptor at 0xfffe8188c250> 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 0xfffe807dc510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807dcb50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> E test_pickle_classmethod_descriptor() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_classmethod_descriptor E module = self.import_extension('pickle_classmethod_desc', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> test_pickle_classmethod_descriptor() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_classmethod_descriptor module = self.import_extension('pickle_classmethod_desc', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________ AppTestPickleCpyextFunction.test_pickle_wrapper_descriptor __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808a44d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80733690> 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 0xfffe80733910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80733910> 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 0xfffe80733a00> 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 0xfffe80733aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80733aa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pickle_wrapper_descriptor at 0xfffe8188c2d0> 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 0xfffe807f2990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80815710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_pickle_wrapper_descriptor() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_wrapper_descriptor E module = self.import_extension('pickle_wrapper_desc', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_pickle_wrapper_descriptor() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_pickle_wrapper_descriptor module = self.import_extension('pickle_wrapper_desc', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestCall.test_code_new_empty ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808a43d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807ae5f0> 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 0xfffe807aeaf0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807aeaf0> 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 0xfffe807ae410> 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 0xfffe807ae960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807ae960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_code_new_empty at 0xfffe8188c350> 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 0xfffe807049d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80704990> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 150, in <module> E test_code_new_empty() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_code_new_empty E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 150, in <module> test_code_new_empty() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_code_new_empty module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________________ AppTestCall.test_get_xxx ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80833950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80800730> 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 0xfffe8082b9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8082b9b0> 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 0xfffe8082beb0> 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 0xfffe8082b0a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8082b0a0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_get_xxx at 0xfffe8188c3d0> 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 0xfffe807fe050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807fefd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 198, in <module> E test_get_xxx() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_xxx E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 198, in <module> test_get_xxx() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_xxx module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestCoroutine.test_generator_coroutine ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806df8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806ee280> 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 0xfffe806eef50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806eef50> 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 0xfffe806ee8c0> 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 0xfffe806eee60> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806eee60> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_generator_coroutine at 0xfffe81926350> 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 0xfffe807dc390>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807dc650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_generator_coroutine() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_generator_coroutine E module = self.import_extension('test_gen', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_generator_coroutine() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_generator_coroutine module = self.import_extension('test_gen', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestCoroutine.test_await __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808a4c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80612410> 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 0xfffe80612500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80612500> 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 0xfffe806125a0> 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 0xfffe80612690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80612690> 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-aarch64/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 0xfffe807fa990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80764610> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_await() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_await E module = self.import_extension('test_coroutine', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_await() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_await module = self.import_extension('test_coroutine', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestGetargs.test_pyarg_parse_int ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8079d1d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8061d910> 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 0xfffe8061d9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8061d9b0> 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 0xfffe8061daa0> 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 0xfffe8061da00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8061da00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_int at 0xfffe81935250> 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 0xfffe807c5d10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807c5990> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_pyarg_parse_int() E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in test_pyarg_parse_int E oneargint = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_pyarg_parse_int() File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in test_pyarg_parse_int oneargint = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestGetargs.test_pyarg_parse_fromname ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807bd6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80756140> 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 0xfffe807561e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807561e0> 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 0xfffe80756d20> 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 0xfffe80756230> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80756230> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_fromname at 0xfffe819352d0> 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 0xfffe807660d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80766550> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_pyarg_parse_fromname() E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_fromname E oneargandform = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_pyarg_parse_fromname() File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_fromname oneargandform = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestGetargs.test_pyarg_parse_object ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8079d1d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807d24b0> 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 0xfffe807d2690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807d2690> 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 0xfffe807d2140> 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 0xfffe807d2870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807d2870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_object at 0xfffe81935350> 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 0xfffe8071afd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8071ae10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_pyarg_parse_object() E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in test_pyarg_parse_object E oneargobject = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_pyarg_parse_object() File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in test_pyarg_parse_object oneargobject = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________ AppTestGetargs.test_pyarg_parse_restricted_object_type ____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806df8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806464b0> 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 0xfffe80646690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80646690> 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 0xfffe80646780> 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 0xfffe80646820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80646820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_restricted_object_type at 0xfffe819353d0> 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 0xfffe807669d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807667d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> E test_pyarg_parse_restricted_object_type() E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_restricted_object_type E oneargobjectandlisttype = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> test_pyarg_parse_restricted_object_type() File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_restricted_object_type oneargobjectandlisttype = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestGetargs.test_pyarg_parse_one_optional _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807bdcd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806120f0> 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 0xfffe80612410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80612410> 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 0xfffe80646550> 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 0xfffe80646730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80646730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_one_optional at 0xfffe81935450> 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 0xfffe8086c150>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8086c710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_pyarg_parse_one_optional() E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_one_optional E twoopt = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_pyarg_parse_one_optional() File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_one_optional twoopt = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestGetargs.test_pyarg_parse_string_py_buffer _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807dd2d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe805db7d0> 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 0xfffe805dba50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805dba50> 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 0xfffe805dbaf0> 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 0xfffe805dbbe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805dbbe0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_string_py_buffer at 0xfffe819354d0> 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 0xfffe8072bf10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8072b890> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> E test_pyarg_parse_string_py_buffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in test_pyarg_parse_string_py_buffer E pybuffer = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> test_pyarg_parse_string_py_buffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in test_pyarg_parse_string_py_buffer pybuffer = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestGetargs.test_pyarg_parse_string_fails _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80881750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8061dc80> 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 0xfffe807888c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807888c0> 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 0xfffe807884b0> 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 0xfffe80788370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80788370> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_string_fails at 0xfffe81935550> 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 0xfffe8071ae10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8071a150> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> E test_pyarg_parse_string_fails() E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_string_fails E pybuffer = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> test_pyarg_parse_string_fails() File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_string_fails pybuffer = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________ AppTestGetargs.test_pyarg_parse_charbuf_and_length ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80805d50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe805dbbe0> 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 0xfffe805db870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805db870> 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 0xfffe805db230> 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 0xfffe8061d320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8061d320> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_charbuf_and_length at 0xfffe819355d0> 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 0xfffe8076ded0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8076df90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_pyarg_parse_charbuf_and_length() E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_charbuf_and_length E charbuf = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_pyarg_parse_charbuf_and_length() File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_pyarg_parse_charbuf_and_length charbuf = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestGetargs.test_pyarg_parse_with_py_ssize_t ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806df8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806015a0> 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 0xfffe80601640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80601640> 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 0xfffe80601730> 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 0xfffe80601690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80601690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_with_py_ssize_t at 0xfffe81935650> 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 0xfffe8076d790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe807663d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_pyarg_parse_with_py_ssize_t() E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_pyarg_parse_with_py_ssize_t E charbuf = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_pyarg_parse_with_py_ssize_t() File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_pyarg_parse_with_py_ssize_t charbuf = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________ AppTestGetargs.test_pyarg_parse_with_py_ssize_t_bytes _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80805d50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806010a0> 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 0xfffe805db870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805db870> 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 0xfffe805db230> 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 0xfffe805dbbe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805dbbe0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyarg_parse_with_py_ssize_t_bytes at 0xfffe819356d0> 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 0xfffe8076d910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8076d9d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_pyarg_parse_with_py_ssize_t_bytes() E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_pyarg_parse_with_py_ssize_t_bytes E charbuf = self.import_parser( E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser E mod = self.import_extension( E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_pyarg_parse_with_py_ssize_t_bytes() File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_pyarg_parse_with_py_ssize_t_bytes charbuf = self.import_parser( ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 113, in w_import_parser mod = self.import_extension( ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestGetargs.test_getargs_keywords _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805eb350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8068b550> 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 0xfffe8068b7d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8068b7d0> 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 0xfffe8068b870> 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 0xfffe8068b960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8068b960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getargs_keywords at 0xfffe81935750> 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 0xfffe80605d10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80605490> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> E test_getargs_keywords() E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in test_getargs_keywords E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> test_getargs_keywords() File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in test_getargs_keywords module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________________ AppTestGetargs.test_y _____________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80881750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8063e230> 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 0xfffe80760910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80760910> 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 0xfffe80601640> 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 0xfffe8068b0f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8068b0f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_y at 0xfffe819357d0> 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 0xfffe80634750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80634250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 160, in <module> E test_y() E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_y E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 160, in <module> test_y() File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_y module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________________ AppTestGetargs.test_d _____________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805eb350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8067f820> 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 0xfffe8067fa00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8067fa00> 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 0xfffe8067faf0> 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 0xfffe8067fb90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8067fb90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_d at 0xfffe81935850> 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 0xfffe806d4490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80605550> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_d() E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_d E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_d() File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_d module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestGetargs.test_d_index __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805ebc50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806785f0> 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 0xfffe80678690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80678690> 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 0xfffe80678780> 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 0xfffe806786e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806786e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_d_index at 0xfffe819358d0> 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 0xfffe806056d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80605710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_d_index() E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_d_index E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_d_index() File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_d_index module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestGetargs.test_f_index __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805eb350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8063e730> 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 0xfffe8063e5a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8063e5a0> 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 0xfffe8063eaa0> 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 0xfffe806e4910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806e4910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_f_index at 0xfffe81935950> 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 0xfffe80608b90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805f9190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_f_index() E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in test_f_index E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_f_index() File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in test_f_index module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestGetargs.test_nested_tuple_es ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe808637d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806ba640> 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 0xfffe806ba6e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806ba6e0> 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 0xfffe806ba7d0> 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 0xfffe806ba910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806ba910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_nested_tuple_es at 0xfffe819359d0> 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 0xfffe80605550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80605f90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_nested_tuple_es() E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_nested_tuple_es E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_nested_tuple_es() File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in test_nested_tuple_es module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestImportLogic.test_import_logic _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807c01d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806bad70> 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 0xfffe806259b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806259b0> 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 0xfffe80625960> 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 0xfffe8073ebe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8073ebe0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_import_logic at 0xfffe81817ed0> 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 0xfffe805f9ad0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805f9410> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> E test_import_logic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_import_logic E path = self.compile_module('test_import_module', E ^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 77, in w_compile_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in <module> test_import_logic() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_import_logic path = self.compile_module('test_import_module', ^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 77, in w_compile_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestImportLogic.test_getmodule _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807225d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806b5a00> 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 0xfffe806b5af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806b5af0> 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 0xfffe806b5b90> 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 0xfffe806b5c80> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806b5c80> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getmodule at 0xfffe81817f50> 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 0xfffe80605f90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80605bd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_getmodule() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_getmodule E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_getmodule() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_getmodule module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________ AppTestIterator.test_noniterable_object_with_mapping_interface ________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8068c450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8051a3c0> 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 0xfffe8051a4b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8051a4b0> 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 0xfffe8051a5f0> 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 0xfffe8051a550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8051a550> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_noniterable_object_with_mapping_interface at 0xfffe8181dad0> 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 0xfffe80672dd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80672ed0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 176, in <module> E test_noniterable_object_with_mapping_interface() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_noniterable_object_with_mapping_interface E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 176, in <module> test_noniterable_object_with_mapping_interface() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_noniterable_object_with_mapping_interface module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestIterator.test_iterable_nonmapping_object ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807e4550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80625be0> 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 0xfffe80935dc0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80935dc0> 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 0xfffe80935910> 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 0xfffe80935640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80935640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_iterable_nonmapping_object at 0xfffe8181db50> 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 0xfffe8067b610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8067b950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 182, in <module> E test_iterable_nonmapping_object() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iterable_nonmapping_object E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 182, in <module> test_iterable_nonmapping_object() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_iterable_nonmapping_object module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestListObject.test_basic_listobject ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805927d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806b5af0> 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 0xfffe806252d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806252d0> 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 0xfffe806258c0> 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 0xfffe805f41e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805f41e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_basic_listobject at 0xfffe8182f5d0> 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 0xfffe80692890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80692b10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 212, in <module> E test_basic_listobject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_basic_listobject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 212, in <module> test_basic_listobject() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_basic_listobject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestListObject.test_list_spec _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805ea1d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe805306e0> 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 0xfffe80530960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80530960> 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 0xfffe80530a50> 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 0xfffe80530af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80530af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_list_spec at 0xfffe8182f650> 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 0xfffe806724d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80673c10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 170, in <module> E test_list_spec() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_list_spec E module = self.import_extension("foo", [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 170, in <module> test_list_spec() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_list_spec module = self.import_extension("foo", [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestListObject.test_list_macros ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805927d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80625cd0> 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 0xfffe8060b8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8060b8c0> 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 0xfffe8060b460> 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 0xfffe8060b2d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8060b2d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_list_macros at 0xfffe8182f6d0> 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 0xfffe80867b90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80867f50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> E test_list_macros() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_list_macros E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> test_list_macros() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_list_macros module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestListObject.test_get_item_macro _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8068c450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe805a6500> 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 0xfffe805a6780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805a6780> 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 0xfffe805a6870> 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 0xfffe805a6910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805a6910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_get_item_macro at 0xfffe8182f750> 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 0xfffe80692710>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80634250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> E test_get_item_macro() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_item_macro E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> test_get_item_macro() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_get_item_macro module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestListObject.test_item_refcounts _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80621950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806c1d20> 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 0xfffe806c1730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806c1730> 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 0xfffe80625cd0> 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 0xfffe80625320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80625320> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_item_refcounts at 0xfffe8182f7d0> 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 0xfffe8067b4d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8067b650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 202, in <module> E test_item_refcounts() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_item_refcounts E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 202, in <module> test_item_refcounts() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_item_refcounts module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestLongObject.test_fromunsignedlong ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805ea250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80655fa0> 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 0xfffe80655320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80655320> 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 0xfffe80655d20> 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 0xfffe80655be0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80655be0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromunsignedlong at 0xfffe8184a550> 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 0xfffe80692bd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80692850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_fromunsignedlong() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromunsignedlong E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_fromunsignedlong() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromunsignedlong module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestLongObject.test_fromlonglong ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8064bed0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80550550> 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 0xfffe805505f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805505f0> 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 0xfffe805506e0> 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 0xfffe80550820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80550820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromlonglong at 0xfffe8184a5d0> 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 0xfffe8065b390>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805430d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> E test_fromlonglong() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromlonglong E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> test_fromlonglong() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromlonglong module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestLongObject.test_from_size_t ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807854d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe807bbaf0> 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 0xfffe807bbb40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807bbb40> 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 0xfffe807bb280> 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 0xfffe807bb460> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe807bb460> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_from_size_t at 0xfffe8184a650> 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 0xfffe80867910>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80673d10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_from_size_t() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_from_size_t E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_from_size_t() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_from_size_t module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestLongObject.test_from_long _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80600750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8057f550> 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 0xfffe8057f5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8057f5f0> 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 0xfffe8057f6e0> 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 0xfffe8057f820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8057f820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_from_long at 0xfffe8184a6d0> 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 0xfffe805a1a50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805a1290> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_from_long() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_from_long E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_from_long() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_from_long module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestLongObject.test_fromstring _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807854d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806b8140> 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 0xfffe80655320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80655320> 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 0xfffe80655fa0> 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 0xfffe80655d20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80655d20> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromstring at 0xfffe8184a750> 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 0xfffe805a1550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80597f10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_fromstring() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromstring E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_fromstring() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromstring module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestLongObject.test_frombytearray _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80785e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8056f780> 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 0xfffe8056f870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8056f870> 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 0xfffe8056f910> 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 0xfffe8056fa00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8056fa00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_frombytearray at 0xfffe8184a7d0> 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 0xfffe80692c90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805447d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_frombytearray() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_frombytearray E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_frombytearray() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_frombytearray module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestLongObject.test_frombytearray_2 ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe807854d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8056f5f0> 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 0xfffe805f41e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805f41e0> 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 0xfffe80535c80> 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 0xfffe80535d20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80535d20> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_frombytearray_2 at 0xfffe8184a850> 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 0xfffe8065be10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8065b850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_frombytearray_2() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_frombytearray_2 E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_frombytearray_2() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_frombytearray_2 module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestLongObject.test_asbytearray ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80694850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804595f0> 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 0xfffe804597d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804597d0> 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 0xfffe804598c0> 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 0xfffe80459960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80459960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_asbytearray at 0xfffe8184a8d0> 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 0xfffe80867bd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805a1a10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 162, in <module> E test_asbytearray() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_asbytearray E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 162, in <module> test_asbytearray() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_asbytearray module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestLongObject.test_fromunicode ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8053c6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8045b370> 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 0xfffe8045b550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8045b550> 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 0xfffe8045b640> 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 0xfffe8045b6e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8045b6e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromunicode at 0xfffe8184a950> 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 0xfffe805977d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80597410> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_fromunicode() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromunicode E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_fromunicode() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromunicode module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestLongObject.test_fromunicodeobject ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805ea250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80459640> 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 0xfffe804598c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804598c0> 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 0xfffe80459cd0> 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 0xfffe80459050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80459050> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromunicodeobject at 0xfffe8184a9d0> 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 0xfffe80672050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805a9e90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_fromunicodeobject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromunicodeobject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_fromunicodeobject() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromunicodeobject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestLongObject.test_aslong _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8053c6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80473730> 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 0xfffe804737d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804737d0> 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 0xfffe804738c0> 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 0xfffe80473820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80473820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_aslong at 0xfffe8184aa50> 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 0xfffe80588d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80588450> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 215, in <module> E test_aslong() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_aslong E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 215, in <module> test_aslong() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_aslong module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestLongObject.test_strtol _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8053c650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80480730> 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 0xfffe80480820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80480820> 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 0xfffe804808c0> 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 0xfffe804809b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804809b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_strtol at 0xfffe8184aad0> 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 0xfffe80554b90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80554690> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_strtol() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_strtol E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_strtol() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_strtol module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestLongObject.test_slots _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8053c6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe81826780> 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 0xfffe804737d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804737d0> 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 0xfffe80473eb0> 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 0xfffe80473730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80473730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_slots at 0xfffe8184ab50> 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 0xfffe80588b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80588e90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_slots() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_slots E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_slots() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_slots module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________ AppTestLongObject.test_PyLong_AsUnsignedLongLongMask _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8053c650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804c1460> 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 0xfffe804c1550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c1550> 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 0xfffe804c15f0> 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 0xfffe804c16e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c16e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyLong_AsUnsignedLongLongMask at 0xfffe8184abd0> 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 0xfffe80597610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80554a50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_PyLong_AsUnsignedLongLongMask() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyLong_AsUnsignedLongLongMask E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_PyLong_AsUnsignedLongLongMask() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyLong_AsUnsignedLongLongMask module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestLongObject.test_as_longlong_and_overflow ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8053c6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804cff50> 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 0xfffe804cffa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804cffa0> 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 0xfffe8065da50> 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 0xfffe8065d280> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8065d280> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_as_longlong_and_overflow at 0xfffe8184ac50> 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 0xfffe80457810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80450490> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_as_longlong_and_overflow() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_as_longlong_and_overflow E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_as_longlong_and_overflow() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_as_longlong_and_overflow module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________ AppTestMarshal.test_PyMarshal_ReadObjectFromString ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806984d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804c1190> 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 0xfffe804c1fa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c1fa0> 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 0xfffe804c1d20> 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 0xfffe804c16e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c16e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyMarshal_ReadObjectFromString at 0xfffe817780d0> 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 0xfffe80489890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80489e10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_PyMarshal_ReadObjectFromString() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyMarshal_ReadObjectFromString E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_PyMarshal_ReadObjectFromString() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyMarshal_ReadObjectFromString module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________ AppTestMarshal.test_PyMarshal_WriteObjectToString _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8064bd50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8047a370> 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 0xfffe8075b8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8075b8c0> 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 0xfffe8065d460> 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 0xfffe8065d140> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8065d140> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyMarshal_WriteObjectToString at 0xfffe81778150> 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 0xfffe80450510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80450090> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_PyMarshal_WriteObjectToString() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyMarshal_WriteObjectToString E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_PyMarshal_WriteObjectToString() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyMarshal_WriteObjectToString module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestPyBuffer.test_fillWithObject ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806008d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80406640> 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 0xfffe80406730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80406730> 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 0xfffe804067d0> 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 0xfffe804068c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804068c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fillWithObject at 0xfffe81788650> 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 0xfffe804891d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80489110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> E test_fillWithObject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fillWithObject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> test_fillWithObject() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fillWithObject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestPyBuffer.test_fromobject ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80695550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80693d70> 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 0xfffe806255a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe806255a0> 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 0xfffe804c1aa0> 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 0xfffe804c1e10> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c1e10> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromobject at 0xfffe81788750> 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 0xfffe805c6810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805c68d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> E test_fromobject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromobject E foo = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in <module> test_fromobject() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_fromobject foo = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestPyBuffer.test_buffer_protocol_app ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806984d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804c6c80> 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 0xfffe804c6af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c6af0> 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 0xfffe804c6960> 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 0xfffe804c6f50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804c6f50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_buffer_protocol_app at 0xfffe817887d0> 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 0xfffe80450350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80450250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_buffer_protocol_app() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_buffer_protocol_app E module = self.import_module(name='buffer_test') E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_buffer_protocol_app() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_buffer_protocol_app module = self.import_module(name='buffer_test') ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestPyBuffer.test_buffer_protocol_capi ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80695550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804b5460> 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 0xfffe804b5780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804b5780> 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 0xfffe804b57d0> 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 0xfffe804b5820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804b5820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_buffer_protocol_capi at 0xfffe81788850> 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 0xfffe8054d650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8054d710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 213, in <module> E test_buffer_protocol_capi() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_buffer_protocol_capi E foo = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 213, in <module> test_buffer_protocol_capi() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_buffer_protocol_capi foo = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestPyBuffer.test_releasebuffer_gc _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80671550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80398780> 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 0xfffe803989b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803989b0> 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 0xfffe80398a00> 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 0xfffe80398af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80398af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_releasebuffer_gc at 0xfffe817888d0> 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 0xfffe804509d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80450810> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 191, in <module> E test_releasebuffer_gc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_releasebuffer_gc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 191, in <module> test_releasebuffer_gc() File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_releasebuffer_gc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestPyBuffer.test_releasebuffer ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80424050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80496140> 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 0xfffe80496a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80496a00> 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 0xfffe80496500> 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 0xfffe80496a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80496a50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_releasebuffer at 0xfffe81788950> 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 0xfffe8054d990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804b0f10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 190, in <module> E test_releasebuffer() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_releasebuffer E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 190, in <module> test_releasebuffer() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_releasebuffer module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestPyBuffer.test_FromMemory_readonly ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805a8e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe806793c0> 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 0xfffe803987d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803987d0> 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 0xfffe803980a0> 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 0xfffe80398370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80398370> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_FromMemory_readonly at 0xfffe817889d0> 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 0xfffe805c6d10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe805c61d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_FromMemory_readonly() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromMemory_readonly E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_FromMemory_readonly() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromMemory_readonly module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestPyBuffer.test_FromMemory_readwrite ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80424050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe805a2190> 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 0xfffe805a20f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805a20f0> 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 0xfffe805a2730> 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 0xfffe805a2640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe805a2640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_FromMemory_readwrite at 0xfffe81788a50> 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 0xfffe804b0a50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804b0950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_FromMemory_readwrite() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromMemory_readwrite E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_FromMemory_readwrite() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromMemory_readwrite module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestPyBuffer.test_FromBuffer_NULL _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804242d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80414410> 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 0xfffe80414500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80414500> 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 0xfffe804145a0> 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 0xfffe80414690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80414690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_FromBuffer_NULL at 0xfffe81788ad0> 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 0xfffe80668150>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80668e10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_FromBuffer_NULL() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromBuffer_NULL E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_FromBuffer_NULL() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_FromBuffer_NULL module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestPyBuffer.test_release_before_dealloc __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80424050>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803ffbe0> 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 0xfffe803ffaf0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803ffaf0> 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 0xfffe803ffaa0> 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 0xfffe803ffb40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803ffb40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_release_before_dealloc at 0xfffe81788b50> 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 0xfffe80450790>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804b07d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 178, in <module> E test_release_before_dealloc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_release_before_dealloc E module = self.import_extension("foo", [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 178, in <module> test_release_before_dealloc() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_release_before_dealloc module = self.import_extension("foo", [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestMethodObject.test_call_METH_NOARGS ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806959d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80445b40> 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 0xfffe80445be0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80445be0> 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 0xfffe80445cd0> 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 0xfffe80445e10> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80445e10> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_call_METH_NOARGS at 0xfffe817d89d0> 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 0xfffe805c69d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80494790> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_call_METH_NOARGS() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_NOARGS E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_call_METH_NOARGS() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_NOARGS mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestMethodObject.test_call_METH_O _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80669b50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80413370> 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 0xfffe80413550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80413550> 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 0xfffe80413640> 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 0xfffe804136e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804136e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_call_METH_O at 0xfffe817d8a50> 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 0xfffe803b2cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803b2190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_call_METH_O() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_O E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_call_METH_O() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_O mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestMethodObject.test_call_METH_VARARGS __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80671a50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803980f0> 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 0xfffe80398a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80398a00> 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 0xfffe80398870> 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 0xfffe80414690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80414690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_call_METH_VARARGS at 0xfffe817d8ad0> 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 0xfffe803a6950>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80668cd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_call_METH_VARARGS() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_VARARGS E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_call_METH_VARARGS() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_VARARGS mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________ AppTestMethodObject.test_call_METH_VARARGS_FASTCALL ______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80669b50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804f2550> 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 0xfffe804f25f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804f25f0> 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 0xfffe804f26e0> 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 0xfffe804f2640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804f2640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_call_METH_VARARGS_FASTCALL at 0xfffe817d8b50> 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 0xfffe804b09d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80668fd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_call_METH_VARARGS_FASTCALL() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_VARARGS_FASTCALL E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_call_METH_VARARGS_FASTCALL() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_VARARGS_FASTCALL mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestMethodObject.test_call_METH_KEYWORDS __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806959d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803c45f0> 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 0xfffe804cf870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804cf870> 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 0xfffe804cc5f0> 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 0xfffe80477550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80477550> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_call_METH_KEYWORDS at 0xfffe817d8bd0> 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 0xfffe80411890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80411050> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_call_METH_KEYWORDS() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_KEYWORDS E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_call_METH_KEYWORDS() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_KEYWORDS mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________ AppTestMethodObject.test_call_METH_KEYWORDS_FASTCALL _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80669b50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804e7500> 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 0xfffe804e75f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804e75f0> 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 0xfffe804e7690> 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 0xfffe804e7780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804e7780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_call_METH_KEYWORDS_FASTCALL at 0xfffe817d8c50> 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 0xfffe803b2e50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80668e50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 158, in <module> E test_call_METH_KEYWORDS_FASTCALL() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_KEYWORDS_FASTCALL E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 158, in <module> test_call_METH_KEYWORDS_FASTCALL() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_call_METH_KEYWORDS_FASTCALL mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestMethodObject.test_func_attributes ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe806959d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804f2dc0> 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 0xfffe804f2640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804f2640> 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 0xfffe804f2140> 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 0xfffe804f2d20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe804f2d20> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_func_attributes at 0xfffe817d8cd0> 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 0xfffe80402c10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804b0950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 162, in <module> E test_func_attributes() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_func_attributes E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 162, in <module> test_func_attributes() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_func_attributes mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestMethodObject.test_function_as_method __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8044a3d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802e07d0> 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 0xfffe802e0a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e0a50> 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 0xfffe802e0b40> 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 0xfffe802e0be0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e0be0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_function_as_method at 0xfffe817d8d50> 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 0xfffe803c7ed0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80402b90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test_function_as_method() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_function_as_method E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test_function_as_method() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_function_as_method mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestMethodObject.test_check ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80546cd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802e2460> 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 0xfffe802e2550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e2550> 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 0xfffe802e25f0> 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 0xfffe802e26e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e26e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_check at 0xfffe817d8dd0> 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 0xfffe803c7b50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803b21d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_check() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_check E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_check() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_check mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestMethodObject.test_module_attribute ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80671650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802e05f0> 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 0xfffe802e00a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e00a0> 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 0xfffe802e0960> 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 0xfffe802e0f00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e0f00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_module_attribute at 0xfffe817d8e50> 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 0xfffe80402cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804d65d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_module_attribute() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_module_attribute E mod = self.import_extension('MyModule', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_module_attribute() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_module_attribute mod = self.import_extension('MyModule', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestMethodObject.test_callfunc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80442650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802f3460> 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 0xfffe802f3640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802f3640> 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 0xfffe802f3730> 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 0xfffe802f37d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802f37d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_callfunc at 0xfffe817d8ed0> 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 0xfffe804e23d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804e2310> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 161, in <module> E test_callfunc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_callfunc E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 161, in <module> test_callfunc() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_callfunc mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestMethodObject.test_wrapper _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80671650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802e2730> 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 0xfffe802e2f00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e2f00> 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 0xfffe802e26e0> 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 0xfffe802e25f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e25f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_wrapper at 0xfffe817d8f50> 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 0xfffe8050bb10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050bbd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_wrapper() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_wrapper E mod = self.import_module(name="specmethdocstring") E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_wrapper() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_wrapper mod = self.import_module(name="specmethdocstring") ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestMethodObject.test_module_name _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80571ad0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803848c0> 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 0xfffe803849b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803849b0> 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 0xfffe80384a50> 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 0xfffe80384b40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80384b40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_module_name at 0xfffe817da050> 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 0xfffe8050b2d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050b150> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in <module> E test_module_name() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_module_name E mod = self.import_module(name="test_func") E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in <module> test_module_name() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_module_name mod = self.import_module(name="test_func") ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestMethodObject.test_min_max _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80546cd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe804f2e10> 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 0xfffe80401cd0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80401cd0> 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 0xfffe803c4780> 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 0xfffe803c4af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803c4af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_min_max at 0xfffe817da0d0> 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 0xfffe8042b090>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050bd50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in <module> E test_min_max() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_min_max E mod = self.import_module(name="builtin_min_max") E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in <module> test_min_max() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_min_max mod = self.import_module(name="builtin_min_max") ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestMisc.test_pyos_inputhook ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804689d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80363870> 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 0xfffe80363960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80363960> 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 0xfffe80363a00> 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 0xfffe80363af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80363af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pyos_inputhook at 0xfffe817da4d0> 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 0xfffe804d6650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80493790> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_pyos_inputhook() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_pyos_inputhook E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_pyos_inputhook() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_pyos_inputhook module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestModuleObject.test_getdef_basic _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8056a250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8038d730> 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 0xfffe8038d820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8038d820> 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 0xfffe8038d8c0> 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 0xfffe8038d9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8038d9b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getdef_basic at 0xfffe818040d0> 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 0xfffe8035a090>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8035a190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_getdef_basic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getdef_basic E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_getdef_basic() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getdef_basic module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestModuleObject.test_getstate _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8044a3d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803630a0> 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 0xfffe803848c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803848c0> 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 0xfffe80384320> 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 0xfffe80384f00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80384f00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getstate at 0xfffe81804150> 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 0xfffe8050bb90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050b1d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_getstate() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getstate E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_getstate() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getstate module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestModuleObject.test___file__ _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80487150>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802b96e0> 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 0xfffe802b98c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b98c0> 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 0xfffe802b99b0> 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 0xfffe802b9a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b9a50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test___file__ at 0xfffe818041d0> 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 0xfffe80427b10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050be90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test___file__() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test___file__ E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test___file__() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test___file__ module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestModuleObject.test_PyModule_AddType ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804870d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802b05f0> 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 0xfffe802b0690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b0690> 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 0xfffe802b0780> 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 0xfffe802b06e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b06e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyModule_AddType at 0xfffe81804250> 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 0xfffe803788d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80378e90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 154, in <module> E test_PyModule_AddType() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyModule_AddType E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 154, in <module> test_PyModule_AddType() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_PyModule_AddType module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestModuleObject.test_getobject ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80487e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802b9dc0> 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 0xfffe802b9910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b9910> 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 0xfffe802b93c0> 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 0xfffe802b9500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b9500> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getobject at 0xfffe818042d0> 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 0xfffe8050ba50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050bad0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> E test_getobject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getobject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in <module> test_getobject() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_getobject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestModuleObject.test_basic ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80671650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802bd640> 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 0xfffe802bd820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802bd820> 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 0xfffe802bd910> 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 0xfffe802bd9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802bd9b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_basic at 0xfffe81804350> 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 0xfffe8035a210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8050b910> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> E test_basic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_basic E module = self.import_module(name='multiphase', use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in <module> test_basic() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_basic module = self.import_module(name='multiphase', use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestModuleObject.test_getdef ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe803372d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802bdeb0> 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 0xfffe8180de60> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8180de60> 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 0xfffe8038b9b0> 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 0xfffe8038b780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8038b780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_getdef at 0xfffe818043d0> 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 0xfffe8050bad0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80305850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in <module> E test_getdef() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_getdef E module = self.import_module(name='multiphase', use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in <module> test_getdef() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_getdef module = self.import_module(name='multiphase', use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestModuleObject.test_slots1 ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80487350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802115a0> 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 0xfffe80211820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80211820> 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 0xfffe80211910> 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 0xfffe802119b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802119b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_slots1 at 0xfffe81804450> 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 0xfffe802aef90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe802aee90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 167, in <module> E test_slots1() E File "/tmp/pytest/usession-py3.12-228/src.py", line 160, in test_slots1 E module = self.import_module(name='multiphase', body=body, init=init, E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 167, in <module> test_slots1() File "/tmp/pytest/usession-py3.12-228/src.py", line 160, in test_slots1 module = self.import_module(name='multiphase', body=body, init=init, ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestModuleObject.test_slots2 ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80412450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803046e0> 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 0xfffe803040a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803040a0> 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 0xfffe80304d20> 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 0xfffe80304190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80304190> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_slots2 at 0xfffe818044d0> 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 0xfffe802aedd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe802ae550> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 169, in <module> E test_slots2() E File "/tmp/pytest/usession-py3.12-228/src.py", line 162, in test_slots2 E module = self.import_module(name='multiphase', body=body, init=init, E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 169, in <module> test_slots2() File "/tmp/pytest/usession-py3.12-228/src.py", line 162, in test_slots2 module = self.import_module(name='multiphase', body=body, init=init, ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestModuleObject.test_forget_init _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe803eef50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802b0460> 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 0xfffe802bdfa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802bdfa0> 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 0xfffe802bd320> 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 0xfffe802bd690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802bd690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_forget_init at 0xfffe81804550> 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 0xfffe803e2290>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803e2450> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_forget_init() E File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_forget_init E raises(SystemError, self.import_module, name='multiphase', body=body, E File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises E func(*args, **kwargs) E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_forget_init() File "/tmp/pytest/usession-py3.12-228/src.py", line 133, in test_forget_init raises(SystemError, self.import_module, name='multiphase', body=body, File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises func(*args, **kwargs) File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestMultiPhase.test__testmultiphase ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80412450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80251780> 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 0xfffe80251820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80251820> 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 0xfffe80251910> 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 0xfffe80251870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80251870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test__testmultiphase at 0xfffe81804650> 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 0xfffe80295490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8035a290> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 150, in <module> E test__testmultiphase() E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test__testmultiphase E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 150, in <module> test__testmultiphase() File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test__testmultiphase module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestMultiPhase.test_functionality _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804872d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802fea00> 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 0xfffe802fed20> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802fed20> 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 0xfffe802fed70> 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 0xfffe802febe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802febe0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_functionality at 0xfffe818046d0> 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 0xfffe80213110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe802134d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> E test_functionality() E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in test_functionality E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 153, in <module> test_functionality() File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in test_functionality module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestMultiPhase.test_reload _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80412450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80294870> 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 0xfffe817943c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe817943c0> 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 0xfffe803060f0> 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 0xfffe80306820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80306820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_reload at 0xfffe81804750> 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 0xfffe803e21d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803e2bd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_reload() E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in test_reload E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_reload() File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in test_reload module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestMultiPhase.test_try_registration ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804e3350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801f75f0> 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 0xfffe801f7690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801f7690> 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 0xfffe801f7780> 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 0xfffe801f76e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801f76e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_try_registration at 0xfffe818047d0> 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 0xfffe803e2c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe802aeb90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_try_registration() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_try_registration E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_try_registration() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_try_registration module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestMultiPhase.test_bad_modules ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80412450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802bd690> 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 0xfffe802b00a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802b00a0> 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 0xfffe803c4eb0> 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 0xfffe803c4f50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe803c4f50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_bad_modules at 0xfffe818048d0> 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 0xfffe80213bd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe802134d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> E test_bad_modules() E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test_bad_modules E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> test_bad_modules() File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test_bad_modules module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestMultiPhase.test_export_null ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe803cd450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8028a6e0> 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 0xfffe8028a8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8028a8c0> 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 0xfffe8028a9b0> 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 0xfffe8028aa50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8028aa50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_null at 0xfffe81804950> 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 0xfffe804d0d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801e40d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_export_null() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_null E excinfo = raises(SystemError, self.load_from_name, 'export_null') E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises E func(*args, **kwargs) E File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_export_null() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_null excinfo = raises(SystemError, self.load_from_name, 'export_null') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises func(*args, **kwargs) File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestMultiPhase.test_export_uninit _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8040b550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802794b0> 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 0xfffe802795f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802795f0> 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 0xfffe80279550> 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 0xfffe80279870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80279870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_uninit at 0xfffe818049d0> 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 0xfffe801fc250>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801fc110> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_export_uninit() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_uninit E excinfo = raises(SystemError, self.load_from_name, 'export_uninitialized') E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises E func(*args, **kwargs) E File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_export_uninit() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_uninit excinfo = raises(SystemError, self.load_from_name, 'export_uninitialized') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises func(*args, **kwargs) File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestMultiPhase.test_export_raise ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8036ff50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80284820> 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 0xfffe80284aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80284aa0> 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 0xfffe80284b40> 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 0xfffe80284c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80284c30> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_raise at 0xfffe81804a50> 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 0xfffe801e4110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe802130d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_export_raise() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_raise E excinfo = raises(SystemError, self.load_from_name, 'export_raise') E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises E func(*args, **kwargs) E File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_export_raise() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_raise excinfo = raises(SystemError, self.load_from_name, 'export_raise') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises func(*args, **kwargs) File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestMultiPhase.test_export_unreported ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802a29d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe817943c0> 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 0xfffe802e1910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802e1910> 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 0xfffe802e1d70> 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 0xfffe802798c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802798c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_export_unreported at 0xfffe81804ad0> 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 0xfffe801d9890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801d9bd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_export_unreported() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_unreported E excinfo = raises(SystemError, self.load_from_name, 'export_unreported_exception') E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises E func(*args, **kwargs) E File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_export_unreported() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_export_unreported excinfo = raises(SystemError, self.load_from_name, 'export_unreported_exception') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 46, in raises func(*args, **kwargs) File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestMultiPhase.test_unloadable_nonascii __________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p....py", line 139, in test_unloadable_nonascii assert excinfo.value.name == '_testmultiphase_' + name AssertionError > func = <function <lambda> at 0xfffe8040be50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe802848c0> 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 0xfffe80284500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80284500> 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 0xfffe802842d0> 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 0xfffe80284410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80284410> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_unloadable_nonascii at 0xfffe81804b50> 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 0xfffe801fc7d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801d9190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_unloadable_nonascii() E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test_unloadable_nonascii E assert excinfo.value.name == '_testmultiphase_' + name 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-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_unloadable_nonascii() File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in test_unloadable_nonascii assert excinfo.value.name == '_testmultiphase_' + name AssertionError _______________________ AppTestMultiPhase.test_nonascii ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80314850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe803305f0> 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 0xfffe80330870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80330870> 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 0xfffe80330910> 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 0xfffe80330a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80330a00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_nonascii at 0xfffe81804bd0> 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 0xfffe804d5650>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804d57d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> E test_nonascii() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_nonascii E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 149, in <module> test_nonascii() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_nonascii module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestMultiPhase.test_get_module _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804fb150>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8032a4b0> 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 0xfffe8032a5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8032a5f0> 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 0xfffe8032a550> 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 0xfffe8032a870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8032a870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_get_module at 0xfffe81804c50> 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 0xfffe80213190>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80213750> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 142, in <module> E test_get_module() E File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_get_module E module = self.load_from_name("meth_state_access") E ^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name E module = self.import_module(name=self.name, use_imp=True) E ^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 142, in <module> test_get_module() File "/tmp/pytest/usession-py3.12-228/src.py", line 137, in test_get_module module = self.load_from_name("meth_state_access") ^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 114, in w_load_from_name module = self.import_module(name=self.name, use_imp=True) ^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 104, in w_import_module sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestMultiPhase.test_fromdefandspec _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804f5750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80238690> 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 0xfffe802389b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802389b0> 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 0xfffe80238370> 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 0xfffe802381e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802381e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fromdefandspec at 0xfffe81804cd0> 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 0xfffe801ea2d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801ea390> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 169, in <module> E test_fromdefandspec() E File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in test_fromdefandspec E module = self.import_extension("get_mod", [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 169, in <module> test_fromdefandspec() File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in test_fromdefandspec module = self.import_extension("get_mod", [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestNamespace.test_simple _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804a5950>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80348870> 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 0xfffe80348960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80348960> 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 0xfffe80348a00> 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 0xfffe80348af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80348af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_simple at 0xfffe81808650> 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 0xfffe804d5890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804d5710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> E test_simple() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_simple E module = self.import_extension('ns', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' def test_simple(): from types import SimpleNamespace module = self.import_extension('ns', [ ("new", "METH_O", """ return _PyNamespace_New(args); """)], prologue="#include pycore_namespace.h") assert module.new({'a': 1, 'b': 2}) == SimpleNamespace(a=1, b=2) try: test_simple() finally: print("===aefwuiheawiu===") from /tmp/pytest/usession-py3.12-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in <module> test_simple() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_simple module = self.import_extension('ns', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestCNumber.test_Check ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804f5ad0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801ba4b0> 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 0xfffe801ba5f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801ba5f0> 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 0xfffe801ba550> 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 0xfffe801ba870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801ba870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Check at 0xfffe8150a550> 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 0xfffe804d5550>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe804d5ad0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 171, in <module> E test_Check() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_Check E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 171, in <module> test_Check() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_Check mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestCNumber.test_number_tobase _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe805860d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801b0730> 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 0xfffe801b07d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801b07d0> 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 0xfffe801b08c0> 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 0xfffe801b0820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801b0820> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_number_tobase at 0xfffe8150a5d0> 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 0xfffe804d5e10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801fc090> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 168, in <module> E test_number_tobase() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_number_tobase E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 168, in <module> test_number_tobase() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_number_tobase mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestCNumber.test_number_to_ssize_t _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801f6350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8032a5f0> 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 0xfffe8032a370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8032a370> 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 0xfffe8032a8c0> 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 0xfffe8032a050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8032a050> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_number_to_ssize_t at 0xfffe8150a650> 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 0xfffe803bd050>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803bd390> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_number_to_ssize_t() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_number_to_ssize_t E mod = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_number_to_ssize_t() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_number_to_ssize_t mod = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestObject.test_object_malloc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c95d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801f3410> 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 0xfffe801f3280> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801f3280> 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 0xfffe801f3aa0> 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 0xfffe801f3960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801f3960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_object_malloc at 0xfffe8136dc50> 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 0xfffe8019a8d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803bdad0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_object_malloc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_object_malloc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_object_malloc() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_object_malloc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestObject.test_object_calloc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c9550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe800f4460> 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 0xfffe800f45a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800f45a0> 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 0xfffe800f4640> 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 0xfffe800f4730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800f4730> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_object_calloc at 0xfffe8136dcd0> 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 0xfffe801bdf90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801bdd90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_object_calloc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_object_calloc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_object_calloc() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_object_calloc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestObject.test_object_realloc _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c96d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80103820> 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 0xfffe80103aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80103aa0> 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 0xfffe80103b40> 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 0xfffe80103c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80103c30> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_object_realloc at 0xfffe8136dd50> 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 0xfffe801a2dd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801a2fd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> E test_object_realloc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_object_realloc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> test_object_realloc() File "/tmp/pytest/usession-py3.12-228/src.py", line 129, in test_object_realloc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestObject.test_TypeCheck _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804f5750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe800e9690> 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 0xfffe800e9730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800e9730> 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 0xfffe800e9820> 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 0xfffe800e9780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800e9780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_TypeCheck at 0xfffe8136ddd0> 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 0xfffe801a2e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80286dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_TypeCheck() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_TypeCheck E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_TypeCheck() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_TypeCheck module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________________ AppTestObject.test_print ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802facd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801bfb40> 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 0xfffe801bf730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801bf730> 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 0xfffe801bfc30> 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 0xfffe801bf9b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801bf9b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_print at 0xfffe8136de50> 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 0xfffe801a35d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8034e310> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 174, in <module> E test_print() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_print E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 174, in <module> test_print() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_print module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestObject.test_isinstance _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8027d0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801b0050> 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 0xfffe801b0690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801b0690> 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 0xfffe801b0640> 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 0xfffe801b0c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801b0c30> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_isinstance at 0xfffe8136ded0> 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 0xfffe80315090>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801a2b10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 165, in <module> E test_isinstance() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_isinstance E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 165, in <module> test_isinstance() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_isinstance module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestObject.test_format_returns_unicode ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802facd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801a7f50> 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 0xfffe801a7e10> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801a7e10> 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 0xfffe801a7190> 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 0xfffe801bf410> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801bf410> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_format_returns_unicode at 0xfffe8136df50> 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 0xfffe80360350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe803bda90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> E test_format_returns_unicode() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_format_returns_unicode E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> test_format_returns_unicode() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_format_returns_unicode module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________________ AppTestObject.test_Bytes ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8027d0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801ae3c0> 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 0xfffe80103c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80103c30> 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 0xfffe80103820> 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 0xfffe80225320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80225320> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Bytes at 0xfffe8136f050> 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 0xfffe801084d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80108dd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_Bytes() E File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in test_Bytes E module = self.import_extension('test_Bytes', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_Bytes() File "/tmp/pytest/usession-py3.12-228/src.py", line 132, in test_Bytes module = self.import_extension('test_Bytes', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestObject.test_LengthHint _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe804f5750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801c5870> 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 0xfffe801c59b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801c59b0> 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 0xfffe801c5a00> 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 0xfffe801c5aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801c5aa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_LengthHint at 0xfffe8136f0d0> 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 0xfffe801a3590>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801a3350> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_LengthHint() E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in test_LengthHint E module = self.import_extension('test_LengthHint', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_LengthHint() File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in test_LengthHint module = self.import_extension('test_LengthHint', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestObject.test_repr_enter_leave ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c9450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801ab2d0> 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 0xfffe801ab0a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801ab0a0> 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 0xfffe800d4500> 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 0xfffe800d49b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800d49b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_repr_enter_leave at 0xfffe8136f1d0> 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 0xfffe80108610>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8010a5d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 166, in <module> E test_repr_enter_leave() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_repr_enter_leave E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 166, in <module> test_repr_enter_leave() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_repr_enter_leave module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestObject.test_GenericGetSetDict _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8037b650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801ab140> 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 0xfffe801c5320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801c5320> 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 0xfffe801c5500> 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 0xfffe801c55f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801c55f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_GenericGetSetDict at 0xfffe8136f250> 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 0xfffe80108cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80108950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_GenericGetSetDict() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_GenericGetSetDict E module = self.import_extension('test_GenericGetSetDict', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_GenericGetSetDict() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_GenericGetSetDict module = self.import_extension('test_GenericGetSetDict', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________________ AppTestObject.test_Py_Is ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c9450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80176780> 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 0xfffe80176870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80176870> 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 0xfffe80176910> 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 0xfffe80176a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80176a00> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_Py_Is at 0xfffe8136f2d0> 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 0xfffe801085d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8010a3d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_Py_Is() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_Py_Is E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_Py_Is() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_Py_Is module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestObject.test_SetAttrNull ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8037b650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801e28c0> 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 0xfffe801e2190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801e2190> 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 0xfffe801e2af0> 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 0xfffe801e2550> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801e2550> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetAttrNull at 0xfffe8136f350> 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 0xfffe80098110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80098cd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_SetAttrNull() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_SetAttrNull E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_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-2059/out' self.udir = '/tmp/pytest/usession-py3.12-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_SetAttrNull() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_SetAttrNull module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestPyBufferObject.test_fillWithoutObject _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c9450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80176a00> 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 0xfffe80176be0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80176be0> 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 0xfffe801763c0> 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 0xfffe80176050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80176050> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fillWithoutObject at 0xfffe8136f3d0> 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 0xfffe80108690>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801a2f50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 170, in <module> E test_fillWithoutObject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_fillWithoutObject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 170, in <module> test_fillWithoutObject() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_fillWithoutObject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestPyBufferObject.test_fillWithObject ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801cfa50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801736e0> 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 0xfffe80173780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80173780> 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 0xfffe80173870> 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 0xfffe801737d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801737d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fillWithObject at 0xfffe8136f450> 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 0xfffe800ae510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8034e1d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 167, in <module> E test_fillWithObject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_fillWithObject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 167, in <module> test_fillWithObject() File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_fillWithObject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestPyBufferObject.test_fillReadonly ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c9450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801ac0a0> 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 0xfffe801ac8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801ac8c0> 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 0xfffe801ac5a0> 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 0xfffe801acf50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801acf50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fillReadonly at 0xfffe8136f4d0> 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 0xfffe800cf210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe800cf0d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_fillReadonly() E File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_fillReadonly E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_fillReadonly() File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_fillReadonly module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestPyBufferObject.test_decrefObject ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8033a8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801316e0> 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 0xfffe801317d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801317d0> 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 0xfffe80131870> 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 0xfffe80131960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80131960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_decrefObject at 0xfffe8136f550> 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 0xfffe8015cdd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8010b290> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> E test_decrefObject() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_decrefObject E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 146, in <module> test_decrefObject() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_decrefObject module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestPyBufferObject.test_richcomp_nan ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801cf0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801766e0> 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 0xfffe80173320> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80173320> 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 0xfffe80173fa0> 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 0xfffe80173b40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80173b40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_richcomp_nan at 0xfffe8136f5d0> 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 0xfffe800cfc90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80177190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_richcomp_nan() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_richcomp_nan E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_richcomp_nan() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_richcomp_nan module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestFetch.test_occurred __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8025c6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8014ea50> 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 0xfffe8014ed70> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8014ed70> 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 0xfffe8014ef50> 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 0xfffe8014eeb0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8014eeb0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_occurred at 0xfffe812a2850> 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 0xfffe80184d90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80184990> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> E test_occurred() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_occurred E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 135, in <module> test_occurred() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_occurred module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestFetch.test_fetch_and_restore ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8033a750>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80015730> 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 0xfffe80015820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80015820> 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 0xfffe800158c0> 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 0xfffe800159b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800159b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fetch_and_restore at 0xfffe812a28d0> 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 0xfffe801583d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe800cf0d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> E test_fetch_and_restore() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_fetch_and_restore E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 144, in <module> test_fetch_and_restore() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_fetch_and_restore module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestFetch.test_normalize __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8034f350>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80011410> 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 0xfffe80011500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80011500> 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 0xfffe800115a0> 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 0xfffe80011690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80011690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_normalize at 0xfffe812a2950> 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 0xfffe80184cd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8015ce50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> E test_normalize() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_normalize E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 156, in <module> test_normalize() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_normalize module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestFetch.test_normalize_no_exception ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe802c9450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8024c5f0> 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 0xfffe8024c820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8024c820> 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 0xfffe8024ceb0> 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 0xfffe8024c910> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8024c910> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_normalize_no_exception at 0xfffe812a29d0> 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 0xfffe80184250>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80184850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> E test_normalize_no_exception() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_normalize_no_exception E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> test_normalize_no_exception() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_normalize_no_exception module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestFetch.test_SetFromErrno ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8025c450>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80030730> 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 0xfffe800309b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800309b0> 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 0xfffe80030aa0> 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 0xfffe80030b40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80030b40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrno at 0xfffe812a2a50> 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 0xfffe80117350>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe801178d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> E test_SetFromErrno() E File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in test_SetFromErrno E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 145, in <module> test_SetFromErrno() File "/tmp/pytest/usession-py3.12-228/src.py", line 128, in test_SetFromErrno module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestFetch.test_SetFromErrnoWithFilename_basic _______________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801c8e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80015cd0> 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 0xfffe8010ebe0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8010ebe0> 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 0xfffe8010ef50> 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 0xfffe8010ed70> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8010ed70> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilename_basic at 0xfffe812a2ad0> 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 0xfffe80147210>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80147190> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 224, in <module> E test_SetFromErrnoWithFilename_basic() E File "/tmp/pytest/usession-py3.12-228/src.py", line 177, in test_SetFromErrnoWithFilename_basic E module = self.import_extension('foo', codestr, E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 224, in <module> test_SetFromErrnoWithFilename_basic() File "/tmp/pytest/usession-py3.12-228/src.py", line 177, in test_SetFromErrnoWithFilename_basic module = self.import_extension('foo', codestr, ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________ AppTestFetch.test_SetFromErrnoWithFilename_NULL ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8021c8d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80167a00> 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 0xfffe80167eb0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80167eb0> 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 0xfffe80167dc0> 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 0xfffe80167af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80167af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilename_NULL at 0xfffe812a2b50> 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 0xfffe80320f50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80320250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> E test_SetFromErrnoWithFilename_NULL() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilename_NULL E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 141, in <module> test_SetFromErrnoWithFilename_NULL() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilename_NULL module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyUnicode __________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801c8e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ffe46e0> 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 0xfffe7ffe47d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffe47d0> 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 0xfffe7ffe4870> 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 0xfffe7ffe4960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffe4960> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilenameObject__PyUnicode at 0xfffe812a2bd0> 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 0xfffe80013810>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80013a50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 155, in <module> E test_SetFromErrnoWithFilenameObject__PyUnicode() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyUnicode E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 155, in <module> test_SetFromErrnoWithFilenameObject__PyUnicode() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyUnicode module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyLong ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8025c6d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ffd55a0> 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 0xfffe7ffd5820> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffd5820> 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 0xfffe7ffd5910> 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 0xfffe7ffd59b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffd59b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilenameObject__PyLong at 0xfffe812a2c50> 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 0xfffe803202d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80320790> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_SetFromErrnoWithFilenameObject__PyLong() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyLong E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_SetFromErrnoWithFilenameObject__PyLong() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyLong module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyList ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801c8e50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801223c0> 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 0xfffe80122a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80122a50> 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 0xfffe80122e60> 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 0xfffe801227d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801227d0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilenameObject__PyList at 0xfffe812a2cd0> 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 0xfffe80132d50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80132c50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_SetFromErrnoWithFilenameObject__PyList() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyList E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_SetFromErrnoWithFilenameObject__PyList() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyList module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________ AppTestFetch.test_SetFromErrnoWithFilenameObject__PyTuple ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801534d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe800018c0> 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 0xfffe800019b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800019b0> 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 0xfffe80001a50> 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 0xfffe80001b40> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80001b40> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilenameObject__PyTuple at 0xfffe812a2d50> 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 0xfffe801841d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8004f250> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_SetFromErrnoWithFilenameObject__PyTuple() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyTuple E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_SetFromErrnoWithFilenameObject__PyTuple() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__PyTuple module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________ AppTestFetch.test_SetFromErrnoWithFilenameObject__Py_None ___________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800ea250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8015d6e0> 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 0xfffe8015d1e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8015d1e0> 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 0xfffe8015da50> 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 0xfffe8015deb0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8015deb0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_SetFromErrnoWithFilenameObject__Py_None at 0xfffe812a2dd0> 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 0xfffe7ffd8ad0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ffd8a50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_SetFromErrnoWithFilenameObject__Py_None() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__Py_None E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_SetFromErrnoWithFilenameObject__Py_None() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_SetFromErrnoWithFilenameObject__Py_None module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestFetch.test_PyErr_Display ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80175250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8006f730> 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 0xfffe8006f960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8006f960> 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 0xfffe8006f9b0> 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 0xfffe8006faa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8006faa0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyErr_Display at 0xfffe812a2e50> 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 0xfffe80132b90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80132950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> E test_PyErr_Display() E File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_PyErr_Display E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> test_PyErr_Display() File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_PyErr_Display module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestFetch.test_PyErr_Format ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800e1550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80236370> 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 0xfffe802361e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802361e0> 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 0xfffe802390a0> 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 0xfffe802399b0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802399b0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyErr_Format at 0xfffe812a2f50> 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 0xfffe80010990>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8004f5d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> E test_PyErr_Format() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_PyErr_Format E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 152, in <module> test_PyErr_Format() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_PyErr_Format module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestFetch.test_StopIteration_value _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80175250>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff624b0> 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 0xfffe7ff62500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff62500> 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 0xfffe7ff625f0> 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 0xfffe7ff62690> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff62690> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_StopIteration_value at 0xfffe81296050> 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 0xfffe8004fbd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80019310> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_StopIteration_value() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_StopIteration_value E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_StopIteration_value() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_StopIteration_value module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestFetch.test_PyErr_BadInternalCall ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80110850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff5b6e0> 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 0xfffe7ff5b960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff5b960> 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 0xfffe7ff5ba50> 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 0xfffe7ff5baf0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff5baf0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_PyErr_BadInternalCall at 0xfffe812960d0> 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 0xfffe80019490>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80010790> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> E test_PyErr_BadInternalCall() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_PyErr_BadInternalCall E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 134, in <module> test_PyErr_BadInternalCall() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_PyErr_BadInternalCall module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestFetch.test_error_thread_race ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800e1650>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ffd50f0> 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 0xfffe802365a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe802365a0> 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 0xfffe802368c0> 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 0xfffe80031f50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80031f50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_error_thread_race at 0xfffe81296150> 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 0xfffe80019310>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe80132750> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 180, in <module> E test_error_thread_race() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_error_thread_race E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 180, in <module> test_error_thread_race() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_error_thread_race module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________________ AppTestFetch.test_format ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80110a50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe801223c0> 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 0xfffe800315a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe800315a0> 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 0xfffe80031a00> 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 0xfffe80031190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80031190> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_format at 0xfffe812961d0> 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 0xfffe80087f90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe800877d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_format() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_format E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_format() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_format module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestFetch.test_WriteUnraisable _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80119850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff77780> 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 0xfffe7ff77960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff77960> 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 0xfffe7ff77a50> 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 0xfffe7ff77af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff77af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_WriteUnraisable at 0xfffe81296250> 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 0xfffe80075c50>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe800759d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 188, in <module> E test_WriteUnraisable() E File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_WriteUnraisable E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 188, in <module> test_WriteUnraisable() File "/tmp/pytest/usession-py3.12-228/src.py", line 125, in test_WriteUnraisable module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestFetch.test_fetch_normalized ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe801106d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff62c80> 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 0xfffe7ff62050> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff62050> 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 0xfffe7ff62230> 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 0xfffe7ff62460> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff62460> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_fetch_normalized at 0xfffe812962d0> 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 0xfffe8001b690>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8001b950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> E test_fetch_normalized() E File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_fetch_normalized E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 159, in <module> test_fetch_normalized() File "/tmp/pytest/usession-py3.12-228/src.py", line 123, in test_fetch_normalized module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________________ AppTestFetch.test_set_get ___________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80119850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8033d870> 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 0xfffe8009f2d0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8009f2d0> 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 0xfffe8008c9b0> 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 0xfffe801410a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe801410a0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_set_get at 0xfffe81296350> 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 0xfffe80075a90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe800408d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 157, in <module> E test_set_get() E File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_set_get E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 157, in <module> test_set_get() File "/tmp/pytest/usession-py3.12-228/src.py", line 124, in test_set_get module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________ AppTestFetch.test_exc_set_object_broken_subclasscheck _____________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80095c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff245a0> 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 0xfffe7ff24640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff24640> 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 0xfffe7ff24730> 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 0xfffe7ff24870> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff24870> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_exc_set_object_broken_subclasscheck at 0xfffe812963d0> 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 0xfffe7ff58f10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff58650> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_exc_set_object_broken_subclasscheck() E File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_exc_set_object_broken_subclasscheck E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_exc_set_object_broken_subclasscheck() File "/tmp/pytest/usession-py3.12-228/src.py", line 127, in test_exc_set_object_broken_subclasscheck module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestPyMem.test_pymem_alloc _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8033a0d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe812ae230> 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 0xfffe8014c5a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8014c5a0> 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 0xfffe7ff3ef00> 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 0xfffe7ff3e8c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff3e8c0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_pymem_alloc at 0xfffe812cf850> 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 0xfffe8008bb90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe8008bed0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> E test_pymem_alloc() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_pymem_alloc E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 151, in <module> test_pymem_alloc() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_pymem_alloc module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _______________________ AppTestBufferObject.test_signals _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80110c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff32870> 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 0xfffe7ff32960> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff32960> 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 0xfffe7ff32a00> 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 0xfffe7ff32af0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff32af0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_signals at 0xfffe812cfb50> 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 0xfffe7ff72bd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff72a90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> E test_signals() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_signals E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 148, in <module> test_signals() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_signals module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestThreads.test_allow_threads _______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8004cd50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff3ebe0> 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 0xfffe7ff3ef00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff3ef00> 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 0xfffe7ff3e230> 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 0xfffe7ff3e640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff3e640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_allow_threads at 0xfffe8131b2d0> 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 0xfffe7ff72e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff72e10> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> E test_allow_threads() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_allow_threads E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 136, in <module> test_allow_threads() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_allow_threads module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestThreads.test_gilstate _________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80110c50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7fec5820> 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 0xfffe7fec5a00> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fec5a00> 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 0xfffe7fec5af0> 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 0xfffe7fec5b90> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fec5b90> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_gilstate at 0xfffe8131b350> 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 0xfffe7ff72510>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff724d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> E test_gilstate() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_gilstate E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 140, in <module> test_gilstate() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_gilstate module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestThreads.test_finalizing ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800378d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe80229550> 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 0xfffe80229460> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80229460> 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 0xfffe80229690> 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 0xfffe80229640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80229640> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_finalizing at 0xfffe8131b3d0> 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 0xfffe7ff1bcd0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff1bbd0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_finalizing() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_finalizing E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_finalizing() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_finalizing module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestThreads.test_thread_state_get _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8003e4d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe812ae230> 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 0xfffe7ff66190> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff66190> 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 0xfffe7ff66280> 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 0xfffe7ff661e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff661e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_thread_state_get at 0xfffe8131b450> 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 0xfffe7ff41e90>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff41710> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_thread_state_get() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_thread_state_get E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_thread_state_get() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_thread_state_get module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestThreads.test_threadstate_dict _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80076850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7fead500> 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 0xfffe7feadd70> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7feadd70> 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 0xfffe7feadc30> 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 0xfffe7fead780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fead780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_threadstate_dict at 0xfffe8131b550> 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 0xfffe7ff1b750>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7ff16950> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> E test_threadstate_dict() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_threadstate_dict E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 131, in <module> test_threadstate_dict() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_threadstate_dict module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________________ AppTestThreads.test_savethread ________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800370d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe8031b4b0> 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 0xfffe8031b500> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe8031b500> 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 0xfffe7fead230> 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 0xfffe7fead280> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fead280> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_savethread at 0xfffe8131b5d0> 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 0xfffe7fe967d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7fe96f50> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> E test_savethread() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_savethread E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 147, in <module> test_savethread() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_savethread module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ______________________ AppTestThreads.test_thread_and_gil ______________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800767d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7fe789b0> 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 0xfffe7fe78aa0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fe78aa0> 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 0xfffe7fe78b40> 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 0xfffe7fe78c30> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fe78c30> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_thread_and_gil at 0xfffe8131b650> 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 0xfffe7ff72c10>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7fe96e90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 165, in <module> E test_thread_and_gil() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_thread_and_gil E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 165, in <module> test_thread_and_gil() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_thread_and_gil module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________ AppTestThreads.test_nested_pygilstate_ensure _________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8008e850>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff5d8c0> 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 0xfffe7ff5d0f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff5d0f0> 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 0xfffe7ff5d280> 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 0xfffe7ff5d370> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff5d370> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_nested_pygilstate_ensure at 0xfffe8131b6d0> 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 0xfffe7fe61890>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7fe61c90> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> E test_nested_pygilstate_ensure() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_nested_pygilstate_ensure E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 139, in <module> test_nested_pygilstate_ensure() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_nested_pygilstate_ensure module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ____________________ AppTestThreads.test_threadsinitialized ____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe8003e4d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ffc0500> 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 0xfffe7ffc05a0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffc05a0> 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 0xfffe7ffc0690> 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 0xfffe7ffc05f0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffc05f0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_threadsinitialized at 0xfffe8131b750> 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 0xfffe7fe962d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7fe96410> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> E test_threadsinitialized() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_threadsinitialized E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 130, in <module> test_threadsinitialized() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_threadsinitialized module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _____________________ AppTestThreads.test_thread_interrupt _____________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe800768d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ffa0690> 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 0xfffe7ffa0730> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffa0730> 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 0xfffe7ffa0820> 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 0xfffe7ffa0780> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffa0780> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_thread_interrupt at 0xfffe8131b7d0> 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 0xfffe7fe96250>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7fe61790> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 204, in <module> E test_thread_interrupt() E File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_thread_interrupt E module = self.import_extension('disruptor', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 204, in <module> test_thread_interrupt() File "/tmp/pytest/usession-py3.12-228/src.py", line 126, in test_thread_interrupt module = self.import_extension('disruptor', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ___________________ AppTestThreads.test_frame_tstate_tracing ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe7ff36bd0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ff9a500> 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 0xfffe7ff9a640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff9a640> 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 0xfffe7ff9a5f0> 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 0xfffe7ff9a6e0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ff9a6e0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_frame_tstate_tracing at 0xfffe8131b850> 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 0xfffe7fe61110>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7febb910> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 240, in <module> E test_frame_tstate_tracing() E File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_frame_tstate_tracing E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 240, in <module> test_frame_tstate_tracing() File "/tmp/pytest/usession-py3.12-228/src.py", line 122, in test_frame_tstate_tracing module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' _________________________ AppTestPyStrHex.test_simple __________________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80041550>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7ffb4960> 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 0xfffe7ffb4a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffb4a50> 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 0xfffe7ffb4af0> 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 0xfffe7ffb4be0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7ffb4be0> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_simple at 0xfffe81348350> 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 0xfffe7fe960d0>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7febb850> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> E test_simple() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_simple E module = self.import_extension('strhex', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 138, in <module> test_simple() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_simple module = self.import_extension('strhex', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' __________________ AppTestStringToDouble.test_endswith_space ___________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe7ff1d7d0>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe7fe78410> 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 0xfffe7fe788c0> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fe788c0> 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 0xfffe7fe78690> 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 0xfffe7fe78a50> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe7fe78a50> 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-aarch64/build/pypy/goal/pypy3.12-c' target_ = <function test_endswith_space at 0xfffe812d3cd0> 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 0xfffe7fe55690>>, ...} defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...] symbol = 'udir', value = u'/tmp/pytest/usession-py3.12-228' code = <py._code.code.Code object at 0xfffe7fe557d0> def run_with_python(python_, target_, usemodules, **definitions): if python_ is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") defs = [] for symbol, value in sorted(definitions.items()): if isinstance(value, tuple) and isinstance(value[0], py.code.Source): code, args = value defs.append(str(code)) arg_repr = [] for arg in args: if isinstance(arg, types.FunctionType): arg_repr.append(arg.__name__) elif isinstance(arg, types.MethodType): arg_repr.append(arg.__name__) else: arg_repr.append(py3k_repr(arg)) args = ', '.join(arg_repr) defs.append("self.%s = anonymous(%s)\n" % (symbol, args)) elif isinstance(value, types.MethodType): # "def w_method(self)" code = py.code.Code(value) defs.append(str(code.source())) defs.append("type(self).%s = %s\n" % (symbol, value.__name__)) elif isinstance(value, types.ModuleType): name = value.__name__ defs.append("import %s; self.%s = %s\n" % (name, symbol, name)) elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)) or value is None: defs.append("self.%s = %s\n" % (symbol, py3k_repr(value))) check_usemodules = '' if usemodules: usemodules = [_rename_module(name) for name in usemodules] check_usemodules = """\ missing = set(%r).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing""" % usemodules source = list(py.code.Source(target_)) while source[0].startswith(('@py.test.mark.', '@pytest.mark.')): source.pop(0) source = source[1:] pyfile = udir.join('src.py') if isinstance(target_, str): # Special case of a docstring; the function name is the first word. target_name = target_.split('(', 1)[0] else: target_name = target_.__name__ with pyfile.open('w') as f: f.write(helpers % (pypyroot, check_usemodules)) f.write('\n'.join(defs)) f.write('def %s():\n' % target_name) f.write('\n'.join(source)) f.write("\ntry:\n %s()\n" % target_name) f.write('finally:\n print("===aefwuiheawiu===")') helper_dir = os.path.join(pypydir, 'tool', 'cpyext') env = os.environ.copy() env['PYTHONPATH'] = helper_dir res, stdout, stderr = run_subprocess( python_, [str(pyfile)], env=env) print pyfile.read() print "from", str(pyfile) print >> sys.stdout, stdout print >> sys.stderr, stderr if res == 81: py.test.skip('%r was not compiled w/ required usemodules: %r' % (python_, usemodules)) elif res != 0: raise AssertionError( > "Subprocess failed with exit code %s:\n%s" % (res, stderr)) E AssertionError: Subprocess failed with exit code 1: E Traceback (most recent call last): E File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> E test_endswith_space() E File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_endswith_space E module = self.import_extension('foo', [ E ^^^^^^^^^^^^^^^^ E File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension E sys_info = get_sys_info_app(self.udir) E ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app E from distutils.sysconfig import get_python_inc E ModuleNotFoundError: No module named 'distutils' tool/pytest/apptest.py:239: AssertionError ----------------------------- Captured stdout call ----------------------------- # -*- encoding: utf-8 -*- if 1: import sys sys.path.append('/build_dir/pypy-c-jit-linux-aarch64/build') missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names) if missing: if not hasattr(sys, 'pypy_version_info'): # They may be extension modules on CPython name = None for name in missing.copy(): if name in ['cpyext', '_cffi_backend', '_rawffi']: missing.remove(name) continue try: __import__(name) except ImportError: pass else: missing.remove(name) del name if missing: sys.exit(81) del missing def skip(message): print(message) raise SystemExit(0) __builtins__.skip = skip __builtins__.py3k_skip = skip class ExceptionWrapper: pass def raises(exc, *args, **kwargs): if not args: return RaisesContext(exc) func = args[0] args = args[1:] import os try: if isinstance(func, str): if func.startswith((' ', os.linesep, '\n')): # it's probably an indented block, so we prefix if True: # to avoid SyntaxError func = "if True:\n" + func frame = sys._getframe(1) exec(func, frame.f_globals, frame.f_locals) else: func(*args, **kwargs) except exc as e: res = ExceptionWrapper() res.value = e res.traceback = e.__traceback__ return res else: raise AssertionError("DID NOT RAISE") class RaisesContext(object): def __init__(self, expected_exception): self.expected_exception = expected_exception self.excinfo = None def __enter__(self): return self def __exit__(self, *tp): __tracebackhide__ = True if tp[0] is None: raise AssertionError("DID NOT RAISE") self.value = tp[1] return issubclass(tp[0], self.expected_exception) __builtins__.raises = raises class Test: pass self = Test() def w_compile_module(self, name, source_files=None, source_strings=None): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.compile_extension_module(name, source_files=source_files, source_strings=source_strings) type(self).compile_module = w_compile_module def w_debug_collect(self): import gc gc.collect() gc.collect() gc.collect() type(self).debug_collect = w_debug_collect self.here = '/build_dir/pypy-c-jit-linux-aarch64/build/pypy/module/cpyext/test' def w_import_extension(self, modname, functions, prologue="", include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_extension( modname, functions, prologue=prologue, include_dirs=include_dirs, more_init=more_init, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_extension = w_import_extension def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False): from extbuild import get_sys_info_app sys_info = get_sys_info_app(self.udir) return sys_info.import_module( name, init=init, body=body, filename=filename, include_dirs=include_dirs, PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN) type(self).import_module = w_import_module def w_load_module(self, mod, name): from extbuild import get_sys_info_app sys_info = 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-228' 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-228/src.py ===aefwuiheawiu=== ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/tmp/pytest/usession-py3.12-228/src.py", line 143, in <module> test_endswith_space() File "/tmp/pytest/usession-py3.12-228/src.py", line 121, in test_endswith_space module = self.import_extension('foo', [ ^^^^^^^^^^^^^^^^ File "/tmp/pytest/usession-py3.12-228/src.py", line 94, in w_import_extension sys_info = get_sys_info_app(self.udir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/build_dir/pypy-c-jit-linux-aarch64/build/pypy/tool/cpyext/extbuild.py", line 258, in get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' ________________ AppTestSequenceObject.test_sequence_macro_cast ________________ self = <CallInfo when='call' exception: Subprocess failed with exit code 1: Traceback (most recent call last): File "/tmp/p... get_sys_info_app from distutils.sysconfig import get_python_inc ModuleNotFoundError: No module named 'distutils' > func = <function <lambda> at 0xfffe80085a50>, when = 'call' def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" self.when = when self.start = time() try: > self.result = func() ../_pytest/runner.py:150: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > return CallInfo(lambda: ihook(item=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 0xfffe86a98f50> 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 0xfffe81324410> 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 0xfffe80050640> def get_result(self): if self.excinfo is None: return self.result else: ex = self.excinfo if _py3: raise ex[1].with_traceback(ex[2]) > _reraise(*ex) # noqa ../_pytest/vendored_packages/pluggy.py:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0xfffe80050640> 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 Output exceeded 6164480 bytes, remaining output has been truncated program finished with exit code 1 elapsedTime=877.281048